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

Était-ce utile?

La 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.

Autres conseils

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"

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top