Is A Class Library The Correct Project To Use To Store Images As Resources To Be Used By A WPF Project

Viewed 2344

I have loaded a few .jpg files into a class library project under Visual Studio 2015 and set them to build as resource and copy when new. It appears to work fine when I use it with my WPF project. Is there another way to store images into a DLL or is this method correct?

======================================

Update 3/22/2016 5:02 pm

Just for some clarity, I am adding the ImageSource statement to my App.xaml file as Application.Resources section as follows:

<ImageSource x:Key="OkImage">pack://application:,,,/MyStyles;component/ok.png</ImageSource>

Then I reference the OkImage keyword in my WPF window xaml as follows for an image control:

<Image x:Name="image" Source="{DynamicResource OkImage}" 
               Grid.Column="1" HorizontalAlignment="Left" Height="100" Margin="66,25,0,0" Grid.Row="2" VerticalAlignment="Top" Width="100"/>

This is how I am pulling the image out of the .DLL and into the WPF file. The purpose for the .DLL with the images is to share it with others to use the same images on their controls for the current and future projects.

3 Answers
Related