0

I am trying to use the tile brush to add a nice wood texture to my project. I have included a resource file, added the resource and selected the image from the ImageSource drop down. The image appears in the preview but throws an exception when I run the program.

This is the XAML code that has been added for the fill.

<Rectangle.Fill>
     <ImageBrush ImageSource="pack://siteoforigin:,,,/Resources/WoodTexture.bmp" TileMode="Tile"/>
</Rectangle.Fill>

The exception that is thrown is this

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '24' and line position '22'.

Does this have something to do with the way the resource has been loaded in, or am I referencing it wrong?

gcoulby
  • 534
  • 2
  • 10
  • 20
  • 1
    See [this answer](http://stackoverflow.com/a/25714375/1136211), and make sure that you either use a Resource File Pack Uri like `pack://application:,,,/Resources/WoodTexture.bmp` or in XAML just `/Resources/WoodTexture.bmp`. – Clemens Jul 30 '15 at 17:28
  • Thanks that did the trick. Does this mean I don't need the resources file? – gcoulby Jul 30 '15 at 17:38
  • 1
    That's right, you don't need a resource file. See also the last section in [this answer](http://stackoverflow.com/a/15008178/1136211). – Clemens Jul 30 '15 at 17:56

0 Answers0