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 asResources
  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

Reply via email to