Reputation: 123
I've looked at about a dozen different solutions to get this to work and I just can't seem to execute it properly. I have a file cup.png that I placed in a subfolder called /Images/ located in my project folder under "/Visual Studio 2013\Projects\PointOfSale\PointOfSale\Images\cup.png".
The IDE acts like it can find the file and it shows up in the designer view and everything, and I can compile, but the minute I run it I get a XamlParseException error:
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 '7' and line position '14'.
What in the world am I missing here? I've tried all different forms of these to try and get this to work:
<ImageBrush ImageSource="pack://application:,,,/PointOfSale;component/cup.png" Opacity="0.1"/>
<ImageBrush ImageSource="/cup.png" Opacity="0.1"/>
<ImageBrush ImageSource="/Images/cup.png" Opacity="0.1"/>
<ImageBrush ImageSource="/PointOfSale;component/Images/cup.png" Opacity="0.1"/>
Upvotes: 1
Views: 1383
Reputation: 32505
You have a couple of options (your response to my comment did not answer this directly)
BuildAction
of Resource.BuildAction
of Content.If you choose the first option, then replacing the image would require the entire assembly/executable to be replaced. You can reference the image as "assembly;component/Resources/Images/cup.png"
(Note that you need a forward slash at the start of the string).
If you choose the second option, then replacing the image would require you to merely replace the image file. You can reference the image as "/Resources/Images/darkaurora.png"
(Note that you need a forward slash at the start of the string).
Upvotes: 2