3

I am new here, I want to set an Icon on the left side of my program(WPF). I copied it in an Image folder.! Code:

<Window x:Class="Hotelverwaltung.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Icon="..\Fachlogik\Images\icon.png" Title="Hotelverwaltung"
        Height="350" Width="525" Loaded="Window_Loaded">

enter image description here

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
Plex
  • 75
  • 2
  • 10
  • Yes I getting an error: A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll. I created an Images folder on the solution explorer, and moved them with drag and drop in this folder – Plex Mar 22 '14 at 15:17
  • http://i58.tinypic.com/2vx28t5.jpg – Plex Mar 22 '14 at 16:09
  • Hotelverwaltung has a reference to Fachlogik and a using command – Plex Mar 22 '14 at 16:10
  • Does this answer your question? [How to change title bar image in WPF Window?](https://stackoverflow.com/questions/5101895/how-to-change-title-bar-image-in-wpf-window) – StayOnTarget Mar 19 '20 at 14:23

3 Answers3

5

After you posted the image, I see the image is in a different project. That's important to know.

  • Make sure the Build Action for you image is set to "Resource".
  • Make sure the Hotelverwaltung project references Fachlogik.

Then try setting the location like this:

Icon="pack://application:,,,/Fachlogik;component/Images/icon.png"

You can't set a relative path like that to go between projects.

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
0

You used the right property. Just make sure that the image is included in the project (right click on the image in the Solution tree and choose 'Include in project'). Then set the Icon property using the properties window in VS. That should do it.

Nir Smadar
  • 357
  • 2
  • 5
  • 15
0

Try setting the Image path like this

Icon="pack://application:,,,/Hotelverwaltung;component/Fachlogik/Images/icon.png"

Check this link for more details about XamlParseException XAML Parse Exception - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Community
  • 1
  • 1