Setting application icon in Explorer?

Have you selected the icon for your application? (project properties > tab application > symbol and manifest > symbol)


The following example shows how to set a window icon.

By using XAML,

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.MainWindow"
    Icon="WPFIcon1.ico">
</Window>

By using c# code,

Uri iconUri = new Uri("pack://application:,,,/WPFIcon2.ico", UriKind.RelativeOrAbsolute);
this.Icon = BitmapFrame.Create(iconUri);

By using VB,

Dim iconUri As New Uri("pack://application:,,,/WPFIcon2.ico", UriKind.RelativeOrAbsolute)
Me.Icon = BitmapFrame.Create(iconUri)

For more info, refer this.

Tags:

C#

Wpf

Icons