Hi Peter, What you have done should work.
Check that the Build Option of the image files in the assembly is set to Resource (not Embedded Resource/Content/None). Also double check that the file name is capitalized correctly. If it's in a folder, you'll need to include that too: /PathWestImages;component/My/Path/To/File.jpg You shouldn't need to set the bin\Debug path - adding the reference from your main project (and making sure Copy Local = true in the project properties) should ensure it gets copied there. Paul From: [email protected] [mailto:[email protected]] On Behalf Of Peter Maddin Sent: Wednesday, 12 January 2011 2:22 PM To: [email protected] Subject: WPF Images in a resource I am learning WPF so I am very much a newbie. I want to be able to reference images with an Image control from within an assembly. Something similar to the Resources available to WinForms development. According to http://social.msdn.microsoft.com/forums/en-US/wpf/thread/16bce8a4-1ee7-4be9-bd7f-0cc2b0f80cf0/ You 1. Create a control library and include the image files as Resources 2. In your app, add a reference to the library above 3. Access the image files via "/<libraryName>;component/<path to image>" type of relative Uris. For e.g. if your control library is ImageStore.dll, then to refer to foo.png, you'd have "/ImageStore;component/foo.png" In XAML, this can be <Image Source="/ImageStore;component/foo.png" /> I am not sure what a 'control' library is. I assumed that this was a 'class' library (which may be incorrect). I created one called PathWestImages and added a resources file to it and deleted the class added by default. I set it to build to the bin/debug directory of my WPF application. I added a jpg file to my resources class and did a build. I then added a reference to the class library in my WPF application. In my XAML I tried <Image Grid.ColumnSpan="3" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" Stretch="Fill" VerticalAlignment="Stretch" MinHeight="50" Source="/PathWestImages;component/banner.jpg"> But it says it cannot locate banner.jpg. I did some googling and just found http://windowsclient.net/blogs/nidonocu/archive/2008/02/16/wpf-themes-and-control-libraries.aspx so I am fairly sure my preconceptions were invalid. I have not had time to read this fully as I have to go out for a while. I'll try and digest it when I get back. Is there an easy way to do this? Any simple pointers to follow. I thought that while WPF was different to WinForms, being such a graphically rich development environment this sort of thing would be easier than WinForms not harder. Regards Peter
_______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
