Transform any vector format to XAML (DrawingBrush or VisualBrush)

  1. Get InkScape, it’s free!
  2. Export you vector format to XAML to a file: exported.xaml
  3. Go to Microsoft Blend (part of Visual Studio). It was called Expression Blend before VS 2012.
  4. Create a test project (WPF Project, for example) that supports XAML
  5. Open the exported file in XAML and a text editor. Copy the code.
  6. Go back to Blend and in a blank Window (the default Window that is created, for example) and paste the code inside a Panel (like <Grid></Grid>). You will paste a <ViewBox> with lots of things inside.
  7. Your vector graphic appears in the Design screen. Click it.
  8. Choose the menu Tools->Make Brush Resource. Choose VisualBrush or DrawingBrush (I normally select DrawingBrush).
  9. Go the the Resources tab and you will see the new resource that has been created
  10. Copy the code of the resource clicking it, then “View Source”.
  11. Paste it in your project! (a Resource Dictionary should be a good idea!).

Enjoy 😀

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s