w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Best practice for Icon format in XAML(SVG, Path DataPoints, Geometry/XAML, or Font)

It seems that this tool is perfect for you:

https://github.com/BerndK/SvgToXaml

It can browse svg files and can convert them (without using other tools like inkscape or illustrator). It can also create a single xaml file for all svgs in a folder (batch). The you just have to refer the created object like this and you are golden:

<Button>
  <Image Source="{StaticResource cloud_3_iconDrawingImage}"/>
</Button>

Sample app is included.

To answer your question (4 options?)

Option 1 is not possible out of the box (a solution could be https://sharpvectors.codeplex.com/)

Option 2 and 3 seems to be identical - the Path-Object uses a Geometry. To be more precise I prefer using an Image not a Path, because Image has clipping and can contain several PathGeometries with several Colors. The Image can handle MouseClicks better than a Path. The result can look like this:

<DrawingImage x:Key="cloud_3_iconDrawingImage">
  <DrawingImage.Drawing>
    <DrawingGroup ClipGeometry="M0,0 V512 H512 V0 H0 Z">
      <GeometryDrawing Brush="#FF000000" Geometry="F1 M512,512z M0,0z
M409.338,216.254C398.922,161.293 350.672,120.477 293.557,120.477
258.459,120.477 225.926,135.762 203.686,162.061 166.538,152.155
127.607,173.842 116.753,210.84 78.16,222.176 50.6,257.895 50.6,299.303
50.6,350.155 91.97,391.524 143.822,391.524L369.18,391.524C420.03,391.524
461.401,350.155 461.401,299.303 461.4,263.389 440.941,231.457
409.338,216.254z M369.18,351.523L143.821,351.523C114.026,351.523
90.599,328.097 90.599,299.302 90.599,265.224 118.249,239.224
152.785,245.486 141.249,205.89 196.916,183.556 217.426,213.138
222.583,198.556 243.249,160.476 293.557,160.476 331.584,160.476
370.918,186.556 372.221,245.458 397.584,245.556 421.401,263.89
421.401,299.302 421.4,328.098 397.975,351.523 369.18,351.523z" />
    </DrawingGroup>
  </DrawingImage.Drawing>
</DrawingImage>

Note this is the definition of the "Image/Icon" to be stored somewhere in the resources. To show it use it as ImageSource with an image as shown above.

Option 4: I think there are only some icons given there, not my preferred solution, but perhaps I understood your idea with the font wrong.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.