Skip to content

Use SVG designs defined in PrettyNSharp

MarkoPaul0 edited this page May 6, 2018 · 1 revision

The PrettyNSharp library contains xaml dictionary (SVGLibrary.xaml) with predefined SVG graphics. These predefined SVG gaphics can be reused in client project in the form of static resource.

The following is an example of vector defined in SVGLibrary.xaml:

<Path x:Key="Checkmark"
          Data="m 24.87906,133.61014 54.011684,45.32148 1.059053,-1.51247 L 90.406331,162.48567
                141.19098,89.957682 124.80809,78.486256 75.027066,149.58093 37.734728,118.28926 Z">
</Path>

In your WPF application, you want to be able to use that vector doing the following:

<pns:SharpDisplay Height="25" Width="50" Vector="{StaticResource Checkmark}"/>

In order to do that, you need to edit your the App.xaml in your WPF application like so:

<Application [attributes specific to your projects]>
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/PrettyNSharp;component/SVGLibrary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
Clone this wiki locally