I tried to load an image into my WPF project's main window. First I created RESX file called Images.resx (it's in Properties folder). Then I added an image called logo.png into this resource (using VS2010 RESX editor). Images were correctly copied into Resource folder. Then I changed Build Action property from Embedded Resource to Resource. After this I wanted to load my image in XAML.
<Image x:Name="image" Source="/MyProject;component/Resources/Logo.png" />
An image appeared in the preview in Expression Blend but when I compile the program, there is an empty window (without images).
Next I used ResourceDictionary. I created new file - Theme.xaml and added this:
<BitmapImage x:Key="logo" UriSource="/MyProject;component/Resources/Logo.png" />
And in MainWindow.xaml:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/Theme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Image x:Name="image" Source="{StaticResource logo}" />
Again OK in Expression Blend but after compilation... Nothing appears:/
I tried to change back Build Action to Embedded Resource. Nothing happened.
Could anyone tell me how to use embedded resource from RESX file in XAML? Thanks in advance.
Ok. I found the answer... When I add some image into my RESX file, then it appears in Resource folder. Now I have to change Build Action of my RESX file AND IMAGES IN RESOURCES FOLDER