WPF Application Icon when StartURL is a Page

Create an LoadCompleted event on the application (App.xaml).


private void Application_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)

System.Drawing.Bitmap bmp = global::Docs.Properties.Resources.favicon.ToBitmap();
MemoryStream strm = new MemoryStream();
bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
strm.Seek(0, SeekOrigin.Begin);
PngBitmapDecoder pbd = new PngBitmapDecoder(strm, BitmapCreateOptions.None, BitmapCacheOption.Default);
//((System.Windows.Navigation.NavigationWindow)(Application.Current.MainWindow)).Icon = pbd.Frames[0];
Application.Current.MainWindow.Icon = pbd.Frames[0];
Application.Current.MainWindow.Top = 0;
Application.Current.MainWindow.Left = 0;

Took me a couple of hours to find this one.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.