user2527636
user2527636

Reputation:

Bind Window Icon to Image Control

currently i have some problems with bindings in WPF. My project is divided into 2 projects: 1. Library 2. Demo Project including the library.

My demo project has a main window with an icon. Now in ViewModel of this window i open another window which is located in the Library. Then i set the icon of the window in the library to the icon of the main window from demo project.

The window of the library has an Image Control and i bound it to the icon of the window:

<Image Width="32" Height="32" Source="{Binding ElementName=windowPackageInformation, Path=Icon}" />

Window's icon is defined as follows:

Name="windowPackageInformation" Icon="/YPUS_LIB;component/icon_32x32.ico"

In the designer view the image is successfully showing up but when starting the application it fails with an exception saying that the icon is unable to locate.

Does someone have an idea?

Upvotes: 0

Views: 1171

Answers (1)

Nitin Purohit
Nitin Purohit

Reputation: 18580

Your icon (.ico) file should be added to the project you are planning to use it. Build action should be set to Resource.

Try accessing like pack://application:,,,/ReferencedAssembly;component/PossibleSubFolder/Yo‌​urResourceFile.ico

Upvotes: 1

Related Questions