tags:

views:

29

answers:

1

I converted image.png to image.svg using Vector Magic and then to image.xaml using svg2xaml, which according to this is supposed to work with Visual Studio.

After adding image.xaml to the project and setting its build path to resource, I add the following line to my XAML file:

<ContentControl Template="{StaticResource image}" />

According to the tutorial here. But, I'm getting a "Error 1 StaticResource reference 'image' was not found." error.

On this MSDN page, it shows that not adding a previous "declaration" results in an error, but if I already linked the resource in the project, isn't that already taken care of? I also don't know what type the "declaration" would need to include, assuming I need one.

Otherwise, I have no idea what I'm doing wrong.

A: 

Simply marking image.xaml with a build action of "Resource" does not make it a ResourceDictionary or allow it to be referenced inside any XAML file inside of your project. For your above code to work you'll need to:

  1. Have a ResourceDictionary file which contains your image in XAML format. The key inside of your resource inside that dictionary needs to be image. For a blank ResourceDictionary to insert your generated XAML, right-click on your project, and select Add-->Resource Dictionary...

  2. Include a reference to your ResourceDictionary inside of your App/Window/container via the ResourceDictionary/MergedDictionary mechanism described here.

After this, you should be able to use the above StaticResource markup extension in your ContentControl.

micahtan