I converted an Adobe Illustrator file to .xaml using Expression Design 4. Now want to take the ControlTemplate that was generated and use this as as an ImageProperty in the LargeImageSource or SmallImageSource in the MS RibbonControl.RibbonButton. There is an images resource dictionary that has been created and the following code is placed there:
<Viewbox x:Uid="Viewbox_1" Stretch="Uniform">
<Canvas x:Uid="Canvas_1" Width="224" Height="224" Clip="F1 M 0,0L 224,0L 224,224L 0,224L 0,0">
<Canvas x:Uid="Layer_1" x:Name="Layer_1" Width="224" Height="224" Canvas.Left="0" Canvas.Top="0"/>
<Canvas x:Uid="Layer_1_0" x:Name="Layer_1_0" Width="224" Height="224" Canvas.Left="0" Canvas.Top="0">
<Path x:Uid="Path" x:Name="Path" Width="224" Height="224" Canvas.Left="0" Canvas.Top="0.00012207" Stretch="Fill" Data="F1 M 4.8,0.00012207C 2.16,0.00012207 0,2.1468 0,4.77348L 0,219.228C 0,221.853 2.16,224 4.8,224L 219.201,224C 221.84,224 224,221.853 224,219.229L 224,4.77348C 224,2.1468 221.84,0.00012207 219.201,0.00012207L 4.8,0.00012207 Z ">
<Path.Fill>
<LinearGradientBrush x:Uid="LinearGradientBrush_1" StartPoint="0.500003,1" EndPoint="0.500003,3.06538e-006">
<LinearGradientBrush.GradientStops>
<GradientStop x:Uid="GradientStop_1" Color="#FFFDEFB3" Offset="0"/>
<GradientStop x:Uid="GradientStop_2" Color="#FFF8E291" Offset="0.134848"/>
<GradientStop x:Uid="GradientStop_3" Color="#FFF4D570" Offset="0.5"/>
<GradientStop x:Uid="GradientStop_4" Color="#FFF8E291" Offset="0.865152"/>
<GradientStop x:Uid="GradientStop_5" Color="#FFFDEFB3" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Path.Fill>
</Path>
<Path x:Uid="Path_1" x:Name="Path_1" Width="226.667" Height="226.667" Canvas.Left="-1.33333" Canvas.Top="-1.33333" Stretch="Fill" StrokeThickness="2.66667" StrokeMiterLimit="2.75" Stroke="#FF666666" Data="F1 M 224,219.229C 224,221.853 221.84,224 219.2,224L 4.80134,224C 2.16,224 0,221.853 0,219.228L 0,4.77332C 0,2.14799 2.16,0 4.80134,0L 219.2,0C 221.84,0 224,2.14799 224,4.77332L 224,219.229 Z "/>
<Path x:Uid="Line" x:Name="Line" Width="206.112" Height="8" Canvas.Left="10.2715" Canvas.Top="164.591" Stretch="Fill" StrokeThickness="8" StrokeMiterLimit="2.75" Stroke="#FF2A3B8E" Data="F1 M 14.2715,168.591L 212.383,168.591"/>
<Path x:Uid="Path_2" x:Name="Path_2" Width="42.3867" Height="42.3853" Canvas.Left="48.3855" Canvas.Top="147.399" Stretch="Fill" Fill="#FFCF1F3C" Data="F1 M 90.7721,168.594C 90.7721,180.295 81.2868,189.785 69.5775,189.785C 57.8735,189.785 48.3855,180.295 48.3855,168.594C 48.3855,156.887 57.8735,147.399 69.5775,147.399C 81.2868,147.399 90.7721,156.887 90.7721,168.594 Z "/>
<Path x:Uid="Path_3" x:Name="Path_3" Width="42.3867" Height="42.384" Canvas.Left="133.555" Canvas.Top="147.399" Stretch="Fill" Fill="#FF1B75BB" Data="F1 M 175.941,168.594C 175.941,180.295 166.456,189.783 154.747,189.783C 143.043,189.783 133.555,180.295 133.555,168.594C 133.555,156.887 143.043,147.399 154.747,147.399C 166.456,147.399 175.941,156.887 175.941,168.594 Z "/>
<Path x:Uid="Line_4" x:Name="Line_4" Width="68.1093" Height="10.6667" Canvas.Left="119.548" Canvas.Top="64.672" Stretch="Fill" StrokeThickness="10.6667" StrokeMiterLimit="2.75" Stroke="#FF00B6DD" Data="F1 M 124.881,70.0053L 182.324,70.0053"/>
<Path x:Uid="Line_5" x:Name="Line_5" Width="10.6667" Height="76.748" Canvas.Left="148.51" Canvas.Top="32.187" Stretch="Fill" StrokeThickness="10.6667" StrokeMiterLimit="2.75" Stroke="#FF00B6DD" Data="F1 M 153.844,103.602L 153.844,37.5204"/>
<Path x:Uid="Path_6" x:Name="Path_6" Width="35.5831" Height="28.2761" Canvas.Left="136.055" Canvas.Top="13.6534" Stretch="Fill" StrokeThickness="8" StrokeMiterLimit="2.75" Stroke="#FF00B6DD" Fill="#FF00B6DD" Data="F1 M 167.578,37.6095L 153.61,17.7814C 153.485,17.6081 153.286,17.6108 153.167,17.7895L 140.109,37.6041C 139.993,37.7828 140.07,37.9295 140.285,37.9295L 167.413,37.9295C 167.627,37.9295 167.702,37.7868 167.578,37.6095 Z "/>
<Path x:Uid="Path_7" x:Name="Path_7" Width="35.5846" Height="28.2777" Canvas.Left="135.783" Canvas.Top="98.1695" Stretch="Fill" StrokeThickness="8" StrokeMiterLimit="2.75" Stroke="#FF00B6DD" Fill="#FF00B6DD" Data="F1 M 167.137,102.169L 140.01,102.169C 139.794,102.169 139.718,102.315 139.843,102.489L 153.813,122.315C 153.935,122.493 154.134,122.491 154.253,122.309L 167.313,102.497C 167.431,102.317 167.35,102.169 167.137,102.169 Z "/>
<Path x:Uid="Path_8" x:Name="Path_8" Width="28.2794" Height="35.5851" Canvas.Left="180.031" Canvas.Top="52.7121" Stretch="Fill" StrokeThickness="8" StrokeMiterLimit="2.75" Stroke="#FF00B6DD" Fill="#FF00B6DD" Data="F1 M 184.359,56.7671C 184.182,56.6484 184.031,56.7284 184.031,56.9431L 184.031,84.0724C 184.031,84.2844 184.174,84.3617 184.351,84.2377L 204.179,70.2684C 204.357,70.1431 204.354,69.9444 204.174,69.8284L 184.359,56.7671 Z "/>
<Path x:Uid="Path_9" x:Name="Path_9" Width="28.2777" Height="35.5834" Canvas.Left="100.22" Canvas.Top="51.6494" Stretch="Fill" StrokeThickness="8" StrokeMiterLimit="2.75" Stroke="#FF00B6DD" Fill="#FF00B6DD" Data="F1 M 124.169,83.1772C 124.349,83.2972 124.497,83.2159 124.497,83.0025L 124.497,55.8745C 124.497,55.6599 124.355,55.5865 124.176,55.7079L 104.348,69.6759C 104.175,69.8025 104.176,69.9999 104.357,70.1172L 124.169,83.1772 Z "/>
</Canvas>
</Canvas>
</Viewbox>
Currently we are using bitmaps with png files as the image source, but now want to use the above xaml files.
Thank you in advance for any help.
Bill
Use Expression Blend to convert this to a DrawingImage:
Place this XAML in some file where you can see it in the designer.
Select the Viewbox.
Click Tools > Make Brush Resource > Make Drawing Brush.
From the created brush, extract the root DrawingGroup and give it some key.
Create a DrawingImage and assign the Drawing property to the above DrawingGroup.
Assign the DrawingImage to the {Large, Small}ImageSource property.
Related
I have here a set of inordinately complex scalable vector graphic icons which were created using Illustrator, and imported into my WPF app using the Expression Blend and Inkscape hack:
Convert SVG to XAML
I tried various method of importing the original icons, this is above approach is the only way they would import correctly in my app.
So now I need to make my app work on a new smaller resolution, and even when in a ViewBox these icons will not scale.
If I remove the width/height attributes it ruins the SVG and the icon essentially disappears.
<Style x:Key="BenefitsIconFlexBox" TargetType="{x:Type Viewbox}">
<Setter Property="MaxHeight" Value="240"/>
<Setter Property="Height" Value="201"/>
<Setter Property="Margin" Value="10,0,0,10"/>
</Style>
...
<Viewbox Style="{StaticResource BenefitsIconFlexBox}">
<Canvas Width="213.333" Height="213.333" Clip="F1 M 0,0L 213.333,0L 213.333,213.333L 0,213.333L 0,0" UseLayoutRounding="False">
<Path Canvas.Left="0" Canvas.Top="3.05176e-005" Stretch="Fill" Fill="#FFEDEDED" Data="F1 M 213.333,106.667C 213.333,165.579 165.579,213.333 106.667,213.333C 47.7547,213.333 0,165.579 0,106.667C 0,47.7547 47.7547,3.05176e-005 106.667,3.05176e-005C 165.579,3.05176e-005 213.333,47.7547 213.333,106.667 Z "/>
<Canvas Canvas.Left="60.588" Canvas.Top="46.828">
<Path Canvas.Left="17.276" Canvas.Top="0" Stretch="Fill" Fill="#FF424242" Data="F1 M 46.0787,0C 30.1827,0 17.276,13.0107 17.276,28.7973L 17.276,40.3173L 28.7973,40.3173L 28.7973,28.7973C 28.7973,19.308 36.584,11.5213 46.0787,11.5213C 55.5733,11.5213 63.36,19.308 63.36,28.7973L 63.36,40.3173L 74.8813,40.3173L 74.8813,28.7973C 74.8813,13.0107 61.9747,0 46.0787,0 Z "/>
</Canvas>
<Path Canvas.Left="60.588" Canvas.Top="87.1454" Stretch="Fill" Fill="#FFFB8C00" Data="F1 M 141.229,162.136L 72.104,162.136C 65.812,162.136 60.588,156.907 60.588,150.615L 60.588,98.6667C 60.588,92.3747 65.812,87.1454 72.104,87.1454L 141.333,87.1454C 147.625,87.1454 152.855,92.3747 152.855,98.6667L 152.855,150.505C 152.745,156.907 147.625,162.136 141.229,162.136 Z "/>
<Path Canvas.Left="98.0267" Canvas.Top="116.052" Stretch="Fill" Fill="#FFC76E00" Data="F1 M 115.307,124.693C 115.307,129.495 111.469,133.333 106.667,133.333C 101.864,133.333 98.0267,129.495 98.0267,124.693C 98.0267,119.896 101.864,116.052 106.667,116.052C 111.469,116.052 115.307,119.896 115.307,124.693 Z "/>
</Canvas>
</Viewbox>
I am open to using transforms or some c# logic to do the resolution math and scaling, but would prefer to use scaling with the view box.
I am not sure why the SVG goes gonzo when the dimensional data is removed, but surely this is the problem. I feel like if I can get rid of the height and width attributes this would scale.
Any suggestions are welcomed! Thank you.
ViewBox has no concern of it's children's preset sizing attributes. Those are only used as the base but ViewBox is what does the scaling accordingly. So if I say remove the Height/MaxHeight setter's from your associated style template and do the following, notice each ViewBox has a different Height. You could also make a style of the whole thing and avoid the repetitive code but for the sake of a quickie dirty concept example;
<StackPanel>
<Viewbox Height="20" Margin="5">
<Canvas Width="213.333" Height="213.333" Clip="F1 M 0,0L 213.333,0L 213.333,213.333L 0,213.333L 0,0" UseLayoutRounding="False">
<Canvas Canvas.Left="0" Canvas.Top="0">
<Path Width="213.333" Height="213.333" Canvas.Left="0" Canvas.Top="3.05176e-005" Stretch="Fill" Fill="#FFEDEDED" Data="F1 M 213.333,106.667C 213.333,165.579 165.579,213.333 106.667,213.333C 47.7547,213.333 0,165.579 0,106.667C 0,47.7547 47.7547,3.05176e-005 106.667,3.05176e-005C 165.579,3.05176e-005 213.333,47.7547 213.333,106.667 Z "/>
<Canvas Width="92.2653" Height="115.307" Canvas.Left="60.588" Canvas.Top="46.828">
<Path Width="57.6053" Height="40.3173" Canvas.Left="17.276" Canvas.Top="0" Stretch="Fill" Fill="#FF424242" Data="F1 M 46.0787,0C 30.1827,0 17.276,13.0107 17.276,28.7973L 17.276,40.3173L 28.7973,40.3173L 28.7973,28.7973C 28.7973,19.308 36.584,11.5213 46.0787,11.5213C 55.5733,11.5213 63.36,19.308 63.36,28.7973L 63.36,40.3173L 74.8813,40.3173L 74.8813,28.7973C 74.8813,13.0107 61.9747,0 46.0787,0 Z "/>
</Canvas>
<Path Width="92.2667" Height="74.9907" Canvas.Left="60.588" Canvas.Top="87.1454" Stretch="Fill" Fill="#FFFB8C00" Data="F1 M 141.229,162.136L 72.104,162.136C 65.812,162.136 60.588,156.907 60.588,150.615L 60.588,98.6667C 60.588,92.3747 65.812,87.1454 72.104,87.1454L 141.333,87.1454C 147.625,87.1454 152.855,92.3747 152.855,98.6667L 152.855,150.505C 152.745,156.907 147.625,162.136 141.229,162.136 Z "/>
<Path Width="17.28" Height="17.2813" Canvas.Left="98.0267" Canvas.Top="116.052" Stretch="Fill" Fill="#FFC76E00" Data="F1 M 115.307,124.693C 115.307,129.495 111.469,133.333 106.667,133.333C 101.864,133.333 98.0267,129.495 98.0267,124.693C 98.0267,119.896 101.864,116.052 106.667,116.052C 111.469,116.052 115.307,119.896 115.307,124.693 Z "/>
</Canvas>
</Canvas>
</Viewbox>
<Viewbox Height="50" Margin="5">
<Canvas Width="213.333" Height="213.333" Clip="F1 M 0,0L 213.333,0L 213.333,213.333L 0,213.333L 0,0" UseLayoutRounding="False">
<Canvas Canvas.Left="0" Canvas.Top="0">
<Path Width="213.333" Height="213.333" Canvas.Left="0" Canvas.Top="3.05176e-005" Stretch="Fill" Fill="#FFEDEDED" Data="F1 M 213.333,106.667C 213.333,165.579 165.579,213.333 106.667,213.333C 47.7547,213.333 0,165.579 0,106.667C 0,47.7547 47.7547,3.05176e-005 106.667,3.05176e-005C 165.579,3.05176e-005 213.333,47.7547 213.333,106.667 Z "/>
<Canvas Width="92.2653" Height="115.307" Canvas.Left="60.588" Canvas.Top="46.828">
<Path Width="57.6053" Height="40.3173" Canvas.Left="17.276" Canvas.Top="0" Stretch="Fill" Fill="#FF424242" Data="F1 M 46.0787,0C 30.1827,0 17.276,13.0107 17.276,28.7973L 17.276,40.3173L 28.7973,40.3173L 28.7973,28.7973C 28.7973,19.308 36.584,11.5213 46.0787,11.5213C 55.5733,11.5213 63.36,19.308 63.36,28.7973L 63.36,40.3173L 74.8813,40.3173L 74.8813,28.7973C 74.8813,13.0107 61.9747,0 46.0787,0 Z "/>
</Canvas>
<Path Width="92.2667" Height="74.9907" Canvas.Left="60.588" Canvas.Top="87.1454" Stretch="Fill" Fill="#FFFB8C00" Data="F1 M 141.229,162.136L 72.104,162.136C 65.812,162.136 60.588,156.907 60.588,150.615L 60.588,98.6667C 60.588,92.3747 65.812,87.1454 72.104,87.1454L 141.333,87.1454C 147.625,87.1454 152.855,92.3747 152.855,98.6667L 152.855,150.505C 152.745,156.907 147.625,162.136 141.229,162.136 Z "/>
<Path Width="17.28" Height="17.2813" Canvas.Left="98.0267" Canvas.Top="116.052" Stretch="Fill" Fill="#FFC76E00" Data="F1 M 115.307,124.693C 115.307,129.495 111.469,133.333 106.667,133.333C 101.864,133.333 98.0267,129.495 98.0267,124.693C 98.0267,119.896 101.864,116.052 106.667,116.052C 111.469,116.052 115.307,119.896 115.307,124.693 Z "/>
</Canvas>
</Canvas>
</Viewbox>
<Viewbox Height="100" Margin="5">
<Canvas Width="213.333" Height="213.333" Clip="F1 M 0,0L 213.333,0L 213.333,213.333L 0,213.333L 0,0" UseLayoutRounding="False">
<Canvas Canvas.Left="0" Canvas.Top="0">
<Path Width="213.333" Height="213.333" Canvas.Left="0" Canvas.Top="3.05176e-005" Stretch="Fill" Fill="#FFEDEDED" Data="F1 M 213.333,106.667C 213.333,165.579 165.579,213.333 106.667,213.333C 47.7547,213.333 0,165.579 0,106.667C 0,47.7547 47.7547,3.05176e-005 106.667,3.05176e-005C 165.579,3.05176e-005 213.333,47.7547 213.333,106.667 Z "/>
<Canvas Width="92.2653" Height="115.307" Canvas.Left="60.588" Canvas.Top="46.828">
<Path Width="57.6053" Height="40.3173" Canvas.Left="17.276" Canvas.Top="0" Stretch="Fill" Fill="#FF424242" Data="F1 M 46.0787,0C 30.1827,0 17.276,13.0107 17.276,28.7973L 17.276,40.3173L 28.7973,40.3173L 28.7973,28.7973C 28.7973,19.308 36.584,11.5213 46.0787,11.5213C 55.5733,11.5213 63.36,19.308 63.36,28.7973L 63.36,40.3173L 74.8813,40.3173L 74.8813,28.7973C 74.8813,13.0107 61.9747,0 46.0787,0 Z "/>
</Canvas>
<Path Width="92.2667" Height="74.9907" Canvas.Left="60.588" Canvas.Top="87.1454" Stretch="Fill" Fill="#FFFB8C00" Data="F1 M 141.229,162.136L 72.104,162.136C 65.812,162.136 60.588,156.907 60.588,150.615L 60.588,98.6667C 60.588,92.3747 65.812,87.1454 72.104,87.1454L 141.333,87.1454C 147.625,87.1454 152.855,92.3747 152.855,98.6667L 152.855,150.505C 152.745,156.907 147.625,162.136 141.229,162.136 Z "/>
<Path Width="17.28" Height="17.2813" Canvas.Left="98.0267" Canvas.Top="116.052" Stretch="Fill" Fill="#FFC76E00" Data="F1 M 115.307,124.693C 115.307,129.495 111.469,133.333 106.667,133.333C 101.864,133.333 98.0267,129.495 98.0267,124.693C 98.0267,119.896 101.864,116.052 106.667,116.052C 111.469,116.052 115.307,119.896 115.307,124.693 Z "/>
</Canvas>
</Canvas>
</Viewbox>
</StackPanel>
Now say you have that ViewBox placed in say a Grid cell with * sizing on the column/row and you DON'T set a Height/Width value on the ViewBox. Then it will fill whatever space is allowed to it. As the viewing medium (large screen, medium screen, little screen, doesn't matter) changes, it will size itself accordingly using the measurements of it's parent as it's boundary.
I'm designing a game. There is a playing board that will take up a full window and I want it to be resizable. I have created a prototype using Expression Design 4 and exported it as a Xaml file then converted it into a Usercontrol in Blend for Visual Studio 2015. It appears ok (after a few tweaks, of course) but won't resize at runtime.
I notice the resulting Xaml code is littered with Canvas objects, which I know don't resize contained objects. When the example window produced by running the code below is resized smaller, the paths just disappear off the screen.
<Grid>
<Canvas x:Name="Layer_1" Width="1024" Height="768" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,-8,-31">
<Viewbox Canvas.Left="42" Canvas.Top="226.007">
<Path x:Name="Path" Width="680.466" Height="72.9967" Canvas.Left="173.267" Canvas.Top="429.008" Stretch="Fill" StrokeThickness="7" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 176.767,262.506L 218.765,232.508L 265.262,264.006L 313.26,237.007L 377.757,276.005L 434.754,247.507L 493.251,280.505L 539.749,250.507L 584.746,295.505L 634.244,259.506L 683.741,297.004L 730.239,246.007L 769.237,292.505L 821.734,247.507L 850.233,298.504"/>
</Viewbox>
<Path x:Name="Path_0" Width="144.993" Height="333.984" Canvas.Left="248.263" Canvas.Top="304.004" Stretch="Fill" StrokeThickness="7" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 302.76,307.504L 346.258,397.499L 284.761,404.999L 284.761,469.496L 329.759,500.994L 389.756,542.992L 344.758,575.99L 266.762,602.989L 251.763,634.488"/>
</Canvas>
I've searched everywhere but can't find any obvious answers. I'm sure I'm missing some best practices.
The graphic I have designed in Expression Design 4 consists of nine hundred items, all paths that look something like this in the exported Xaml file: -
<Viewbox x:Name="_AreaC_" Width="296.125" Height="159.938" Canvas.Left="171.208" Canvas.Top="143.469">
<Canvas Width="296.125" Height="159.938">
<Path x:Name="Path_35" Width="268.375" Height="159.208" Canvas.Left="27.75" Canvas.Top="0.729187" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 28.9583,3.1875L 34.9167,2.60413L 41.375,2.02087L 47.6666,1.60419L 54.25,1.35419L 64.4583,1.22919L 72.625,1.39587L 81.4166,1.89587L 90,2.47919L 99.75,3.39587L 109.75,4.6875L 116.375,5.6875L 122.833,6.72919L 129.625,8.27087L 136.125,9.77087L 143.917,11.6459L 150.958,13.4375L 160.917,16.5625L 170.292,19.7709L 175.875,21.9792L 182.917,24.7292L 188.375,27.1042L 194.542,29.7292L 201.125,33.0209L 205.375,35.0209L 212.083,38.6459L 220.375,43.0625L 226.208,46.6042L 233.375,50.9792L 238.708,54.3542L 245.125,58.7709L 251.667,63.5625L 258.5,68.7709L 263.875,73.1042L 268.792,77.2708L 273.083,81.0208L 277.208,84.7292L 282.667,89.9375L 288.292,95.5625L 293.167,100.563L 295.625,103.104L 292.542,106.521L 287.458,111.521L 283.708,115.229L 277.583,120.604L 268.208,127.771L 257.583,134.604L 252.75,137.688L 242.208,143.146L 231.583,147.604L 223.5,150.604L 214.292,153.271L 203.625,155.979L 192.833,157.813L 181.917,159.021L 171.542,159.438L 161.792,159.396L 151.5,158.646L 143.875,157.771L 133.792,155.813L 124.292,153.438L 114.417,150.479L 104.25,146.896L 93.625,142.021L 84.5833,137.229L 76.5833,132.271L 69.875,127.563L 66.2083,124.729L 68.9583,120.063L 72.1666,116.146L 75.6666,112.729L 78.9166,110.313L 82.25,108.479L 85.5416,107.146L 88.6666,109.271L 93.875,112.938L 99.1666,115.854L 105.542,119.396L 110.792,121.729L 118.625,124.979L 124.667,127.146L 132.375,129.188L 139.417,131.021L 145.542,132.271L 152.333,133.104L 156.792,133.521L 163.417,133.979L 169.375,134.188L 176.375,133.771L 183.875,133.271L 189.792,132.479L 195.625,131.563L 202.708,130.104L 207.875,128.896L 216.292,126.271L 223.833,123.438L 230.625,120.521L 236.667,117.396L 243.375,113.688L 250.167,109.229L 255.75,105.354L 258.875,102.896L 253.417,97.8542L 245.375,91.2708L 239,86.1875L 232.417,81.4375L 224.708,76.0208L 218.25,71.8125L 211,67.2709L 203.292,63.1459L 196.75,59.5625L 189,55.8542L 182.083,52.4792L 175.5,49.4792L 169,46.9375L 162.792,44.6042L 156.542,42.3125L 149.833,40.1459L 143.167,38.1459L 136.583,36.3542L 131.833,35.3125L 123.125,33.0625L 115.083,31.5625L 107.208,30.1459L 101.583,29.3125L 95.9583,28.7292L 92,28.4792L 82.25,27.6042L 74.3333,27.2709L 66.9166,26.9375L 59.6666,27.0209L 53.125,27.1875L 48.2083,27.5209L 42.0417,27.9792L 36.125,28.3959L 33.4167,28.5209L 31.7917,25.6875L 30.375,22.1042L 29.5,19.4375L 28.5417,14.5209L 28.25,10.3125L 28.375,6.9375L 28.9583,3.1875 Z "/>
<Path x:Name="Line_36" Width="13.875" Height="22.875" Canvas.Left="82.8229" Canvas.Top="113.812" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 96.1979,114.312L 83.3229,136.187"/>
<Path x:Name="Line_37" Width="11" Height="24.6667" Canvas.Left="103.406" Canvas.Top="122.521" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 113.906,123.021L 103.906,146.687"/>
<Path x:Name="Line_38" Width="4.20834" Height="26.5" Canvas.Left="147.365" Canvas.Top="132.229" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 151.073,132.729L 147.865,158.229"/>
<Path x:Name="Line_39" Width="1.58334" Height="26.2917" Canvas.Left="169.156" Canvas.Top="133.479" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 169.656,133.979L 170.24,159.271"/>
<Path x:Name="Line_40" Width="4.58331" Height="26.3333" Canvas.Left="188.948" Canvas.Top="131.979" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 189.448,132.479L 193.031,157.812"/>
<Path x:Name="Line_41" Width="8.04169" Height="25.4583" Canvas.Left="207.781" Canvas.Top="128.062" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 208.281,128.562L 215.323,153.021"/>
<Path x:Name="Line_42" Width="11.0833" Height="24.2917" Canvas.Left="226.115" Canvas.Top="121.604" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 226.615,122.104L 236.698,145.396"/>
<Path x:Name="Path_43" Width="35.8333" Height="50.625" Canvas.Left="242.906" Canvas.Top="85.1875" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 243.406,113.479L 256.406,135.312L 277.448,120.896L 259.24,102.813L 278.24,85.6875"/>
<Path x:Name="Line_44" Width="16.9166" Height="21.4167" Canvas.Left="243.156" Canvas.Top="69.0208" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 243.656,89.9375L 259.573,69.5208"/>
<Path x:Name="Line_45" Width="15.75" Height="22.1667" Canvas.Left="226.031" Canvas.Top="55.6875" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 226.531,77.3542L 241.281,56.1875"/>
<Path x:Name="Line_46" Width="12.4167" Height="24.2083" Canvas.Left="189.615" Canvas.Top="32.6875" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 190.115,56.3958L 201.531,33.1875"/>
<Path x:Name="Line_47" Width="10.6667" Height="24.9583" Canvas.Left="171.781" Canvas.Top="23.8125" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 172.281,48.2708L 181.948,24.3125"/>
<Path x:Name="Line_48" Width="9.16666" Height="25.625" Canvas.Left="153.323" Canvas.Top="16.3958" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 153.823,41.5208L 161.99,16.8958"/>
<Path x:Name="Line_49" Width="7.20834" Height="26.3333" Canvas.Left="133.615" Canvas.Top="10.1458" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 134.115,35.9791L 140.323,10.6458"/>
<Path x:Name="Line_50" Width="3.75" Height="26.75" Canvas.Left="92.1979" Canvas.Top="2.3125" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 92.6979,28.5625L 95.4479,2.8125"/>
<Path x:Name="Line_51" Width="2.33334" Height="26.7083" Canvas.Left="70.7813" Canvas.Top="0.8125" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 71.2813,27.0208L 72.6146,1.3125"/>
<Path x:Name="Line_52" Width="2" Height="27" Canvas.Left="48.3646" Canvas.Top="0.895813" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 49.8646,27.3958L 48.8646,1.39581"/>
<Path x:Name="Line_53" Width="13.625" Height="23.4583" Canvas.Left="208.031" Canvas.Top="43.0625" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 221.156,43.5625L 208.531,66.0208"/>
<Path x:Name="Line_54" Width="26.2083" Height="3.16663" Canvas.Left="0" Canvas.Top="0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Data="F1 M 0.5,2.66663L 25.7083,0.5"/>
</Canvas>
</Viewbox>
My thinking is "When I'm in Expression Design and I select all the objects and resize them they stay in position as a coherent whole to form exactly the same image, as if it were a bitmap. Surely there's a control(or some other way) in a WPF project to have the same thing happen at runtime when the run window is resized by a user?".
Thanks,
Paul.
Not sure what you exactly want to achieve.
But making something resizable with fixed sizes are never a good idea.
As I understood you wanted your paths so be resizable, and I have fixed your code a little bit to give you an idea of how you can go further:
XAML:
<Window x:Class="test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:test="clr-namespace:test"
Title="MainWindow" >
<Window.Resources>
<test:HalfSizeConverter x:Key="HalvSizeConverter"/>
</Window.Resources>
<Grid>
<Path x:Name="Path" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth, Converter={StaticResource HalvSizeConverter}}" Stretch="Fill" StrokeThickness="7" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 176.767,262.506L 218.765,232.508L 265.262,264.006L 313.26,237.007L 377.757,276.005L 434.754,247.507L 493.251,280.505L 539.749,250.507L 584.746,295.505L 634.244,259.506L 683.741,297.004L 730.239,246.007L 769.237,292.505L 821.734,247.507L 850.233,298.504"/>
<Path x:Name="Path_0" VerticalAlignment="Stretch" Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight, Converter={StaticResource HalvSizeConverter}}" HorizontalAlignment="Left" Stretch="Fill" StrokeThickness="7" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 302.76,307.504L 346.258,397.499L 284.761,404.999L 284.761,469.496L 329.759,500.994L 389.756,542.992L 344.758,575.99L 266.762,602.989L 251.763,634.488"/>
</Grid>
Code:
public class HalfSizeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var size = (double) value;
return size/2;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
With the HalfSizeConverter you can define the proportions of the path.
Enjoy
How I can add PathGeometry as an Icon to the style of the button/radbutton?
In resources I have for example:
<PathGeometry x:Key="HomeIconData">F1 M 22,19L 24,19L 24,57L 22,57L 22,19 Z M 26,57L 26,19.0001L 53.9999,19.0001L 53.9999,57L 26,57 Z M 30,24L 30,27L 50,27L 50,24L 30,24 Z M 30,32L 30,35L 33,35L 33,32L 30,32 Z M 36,32L 36,35L 49,35L 49,32L 36,32 Z M 30,40L 30,43L 33,43L 33,40L 30,40 Z M 36,40L 36,43L 48,43L 48,40L 36,40 Z M 30,48L 30,51L 33,51L 33,48L 30,48 Z M 36,48L 36,51L 50,51L 50,48L 36,48 Z</PathGeometry>
With Path I add this to the style:
<Grid Margin="0,30,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="36" Width="41">
<Path HorizontalAlignment="Center" Data="{Binding Source={StaticResource path1}, Path=Data}" Fill="#FFFFFFFF" Height="27" Stretch="Fill" Width="28.167" VerticalAlignment="Bottom" />
</Grid>
How can I do the same with PathGeometry?
Thanks
This should work:
<Path Data="{StaticResource HomeIconData}" ... />
I'm looking for resources (geometry shapes) for WPF
A website like iconfinder.com for instance...
Is there any website for this??
I'd like to have shapes replacing my icons like (save icon, new icon, ...)
Some examples :
<Path Stretch="Fill" Fill="Black" HorizontalAlignment="Left"
Width="12" Height="12" Data="F1 M 151,217L 152,217L 154.5,219.5L 157,217L 158,217L 158,218L 155.5,220.5L 158,223L 158,224L 157,224L 154.5,221.5L 152,224L 151,224L 151,223L 153.5,220.5L 151,218L 151,217 Z">
</Path>
<Separator></Separator>
<Path Data="M0,0 L8,0 8,1 8,2 0,2 0,1 z" Stretch="Uniform" Fill="Black" HorizontalAlignment="Left"
Width="12" Height="12"></Path>
<Separator></Separator>
<Path Data="F1 M 34,17L 43,17L 43,23L 34,23L 34,17 Z M 35,19L 35,22L 42,22L 42,19L 35,19 Z" Stretch="Fill" Fill="Black" HorizontalAlignment="Left"
Width="12" Height="12"></Path>
<Separator></Separator>
<Path Stretch="Fill" Fill="Black" HorizontalAlignment="Left"
Width="12" Height="12" Data="M1,4.9996096 L1,7.000219 7,6.999219 7,5.001 2,5.001 2,4.9996096 z M3,2.0014141 L3,3.0000001 8,3.0000001 8,4.0000001 8,4.0008045 9,4.0008045 9,2.0014141 z M2,0 L10,0 10,0.0010234118 10,1.0000001 10,5.001 8,5.001 8,7.9990235 0,8.0000239 0,4.0000001 0,3.0009998 0,3.0000001 2,3.0000001 2,1.0000001 2,0.0010234118 z"></Path>
You can try this free tool called Metro Studio http://www.syncfusion.com/downloads/metrostudio
has a huge collection of icons that you can use in different formats (xaml being one of them)
You can also try http://www.xamalot.com/ which contains a lot of vector graphics
I want to set the icon color in a MahApp application, but the brush is not working. In this example the icoun should be white, but still it is black.
<Rectangle Width="20" Height="20">
<Rectangle.Resources>
<SolidColorBrush x:Key="BlackBrush" Color="White" />
</Rectangle.Resources>
<Rectangle.Fill>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_cupcake}" />
</Rectangle.Fill>
</Rectangle>
This is the resource icons.xml file in my app.
<Canvas Width="48" Height="48" Clip="F1 M 0,0L 48,0L 48,48L 0,48L 0,0" x:Key="appbar_cupcake">
<Path Width="24" Height="25" Canvas.Left="13" Canvas.Top="11" Stretch="Fill" Fill="{DynamicResource BlackBrush}" Data="F1 M 32,14C 33.1046,14 34,14.8954 34,16C 34,16.3643 33.9026,16.7058 33.7324,17L 34,17C 35.1046,17 36,17.8954 36,19C 36,20.1046 35.1046,21 34,21L 35,21C 36.1046,21 37,21.8954 37,23C 37,24.1046 36.1046,25 35,25L 15,25C 13.8954,25 13,24.1046 13,23C 13,21.8954 13.8954,21 15,21L 16,21C 14.8954,21 14,20.1046 14,19C 14,17.8954 14.8954,17 16,17L 16.2676,17C 16.0974,16.7058 16,16.3643 16,16C 16,14.8954 16.8954,14 18,14C 19,14 21,12 25,11C 29,14 31,14 32,14 Z M 15,26L 35,26L 32,36L 18,36L 15,26 Z " />
</Canvas>
What I'm doing wrong?
If you want to dynamically set the Fill color, you can do that by setting the Fill property. As you can see, you are already using the Fill property for the VisualBrush. Fortunately you can use the VisualBrush also in the OpacityMask property.
<Rectangle Fill="Black">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_cupcake}" Stretch="Fill" />
</Rectangle.OpacityMask>
</Rectangle>
Hope that helps.