Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top