Your technique will depend on which XAML object your SVG uses for the XAML converter. Does it make a drawing? Picture? Grid? Canvas? Way? Geometry? In each case, your technique will be different.
In the examples below, I assume that you are using your icon on a button, which is the most common scenario, but note that the same methods will work for any ContentControl.
Using a drawing as an icon
To use Drawing, draw a rectangle of a suitable size using the DrawingBrush:
<Button> <Rectangle Width="100" Height="100"> <Rectangle.Fill> <DrawingBrush> <DrawingBrush.Drawing> <Drawing ... /> </DrawingBrush.Drawing> </DrawingBrush> </Rectangle.Fill> </Rectangle> </Button>
Using an image as an icon
The image can be used directly:
<Button> <Image ... /> </Button>
Using the grid as an icon
The grid can be used directly:
<Button> <Grid ... /> </Button>
Or you can include it in the viewport if you need to control the size:
<Button> <Viewbox ...> <Grid ... /> </Viewbox> </Button>
Using canvas as an icon
This is similar to using an image or grid, but since the canvas size does not have a fixed size, you need to specify the height and width (if they are not already set by the SVG converter):
<Button> <Canvas Height="100" Width="100"> </Canvas> </Button>
Using path as icon
You can use the Path, but you must set the stroke or fill explicitly:
<Button> <Path Stroke="Red" Data="..." /> </Button>
or
<Button> <Path Fill="Blue" Data="..." /> </Button>
Using geometry as an icon
You can use the Path to draw your geometry. If it should be stroked, set the Stroke:
<Button> <Path Stroke="Red" Width="100" Height="100"> <Path.Data> <Geometry ... /> </Path.Data> </Path> </Button>
or if it should be filled, install Fill:
<Button> <Path Fill="Blue" Width="100" Height="100"> <Path.Data> <Geometry ... /> </Path.Data> </Path> </Button>
How to bind data
If you are converting SVG โ XAML in code and want the resulting XAML to appear using data binding, use one of the following actions:
Linking Pattern:
<Button> <Rectangle Width="100" Height="100"> <Rectangle.Fill> <DrawingBrush Drawing="{Binding Drawing, Source={StaticResource ...}}" /> </Rectangle.Fill> </Rectangle> </Button>
Image Linking:
<Button Content="{Binding Image}" />
Mesh Binding:
<Button Content="{Binding Grid}" />
Grid binding in viewport:
<Button> <Viewbox ...> <ContentPresenter Content="{Binding Grid}" /> </Viewbox> </Button>
Canvas binding:
<Button> <ContentPresenter Height="100" Width="100" Content="{Binding Canvas}" /> </Button>
Path binding:
<Button Content="{Binding Path}" />
Geometry Linking:
<Button> <Path Width="100" Height="100" Data="{Binding Geometry}" /> </Button>