Why is my application icon not transparent?
-
31-05-2021 - |
Domanda
In XAML, I am attempting to bind the window/application icon to an icon on the file system.
In Window.xaml
Icon="{Binding ApplicationIcon}"
In AppViewModel.cs
public ImageSource ApplicationIcon
{
get
{
return new BitmapImage(new Uri(pathReadFromConfigFile));
}
}
When I do this, the icon is shown but it is not transparent. However, if I set the icon within the project (not using binding), the icon is added to the project and it is transparent when I start the application. Why is it acting differently between these two scenarios?
Soluzione
Figured it out. It was the BitMapImage creation causing the problems. Using BitmapFrame now instead.
public ImageSource ApplicationIcon
{
get
{
return BitmapFrame.Create(new Uri(pathReadFromConfigFile));
}
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow