tags:

views:

322

answers:

1

I'm trying to do something rather simple: add a simple icon to the main window of the application. This can be done rather easily. The icon itself is placed in the Resources directory and its build action is set to Resource. The XAML code for the window includes a reference to this icon:

Icon="Resources/wiser.ico"

This works just fine. However, what I really want to do is grab this icon from another place, a directory of images shared across several versions of our application (we support about 5 platforms depending on how you count). In our WinForms past, this was done by adding the resource as an existing item and choosing 'Add as Link' from the dialog. This, however, causes issues with the icon noted above.

First, it doesn't end up in the proper place in the assembly. Reflector finds it in the base path of the application, not within the Resources directory where it should be. A non-linked version of the icon does indeed appear in the Resources directory.

Second, a fix for the path (Icon="wiser.ico") allows things to compile but makes the designer throw an error, rendering the designer itself useless.

I suspect this is just a bug (or two, depending on how you count). Is there a simple way around this? Note that I had hoped to support linking from our source control system instead but that doesn't appear to be supported by SVN and the end result would likely be a touch confusing to maintain.

+1  A: 

Two things that I can think of for sharing resources:

1) You could put your resources in a seperate assembly that you could share across your applications.

Use this syntax for getting the ico or other items (png, xaml, etc) out of the assembly:

Icon="/CommonResources;component/app.ico"

or using pack syntax

Icon="pack://application:,,,/CommonResources;component/app.ico"

2) You could use the pack application syntax to load the ico in a relative file path from your assembly.

Icon="pack://siteoforigin:,,,/app.ico"
John Z
Thanks, but that isn't really the problem. I can address the resource properly, if I could the VS designer to recognize it.
Ken Wootton