Question: There is solution with two projects: **WPFProject** and **WPFResources**. WPFProject has MainWindow.xaml. WPFResources has picture **logo.png**. How can I set **Icon** property for main windows in XAML markup from project **WPFResources**?

Answer: 
See [pack URI syntax](http://msdn.microsoft.com/en-us/library/aa970069%28v=vs.85%29.aspx). Something like:

```
Icon="pack://application:,,,/ReferencedAssembly;component/logo.ico"

```
Let's consider a Visual Studio solution structured like this:

[![Solution Structure](https://i.stack.imgur.com/gfdmR.png)](https://i.stack.imgur.com/gfdmR.png)

* a WPF desktop client project (named `Main` in the example)
* a class-library project (named `Shared` in the example) containing shared code and resources.

Let's assume the Shared project includes an image file called `icon.png` which we want to 
set as the `Main` application icon. The image is stored in the `Resources` folder.

To do so:

1. First the *Build Action* for the `icon.png` file must be set to *Resource*.

[![Set Build Action to Resource](https://i.stack.imgur.com/WMux7.png)](https://i.stack.imgur.com/WMux7.png)

2. Specify the window icon using the [Pack URI](http://learn.microsoft.com/en-us/dotnet/framework/wpf/app-development/pack-uris-in-wpf) for the resource, either in the `MainWindow` constructor (see [here](http://stackoverflow.com/a/8254591/2299407)):

```cs
this.Icon = new BitmapImage(new Uri("pack://application:,,,/Shared;component/Resources/icon.png"));

```

or directly in the XAML for `MainWindow`:

[![enter image description here](https://i.stack.imgur.com/rGpPy.png)](https://i.stack.imgur.com/rGpPy.png)