How to change title bar image in WPF Window?

后端 未结 6 2317
太阳男子
太阳男子 2020-12-14 14:58

How to change the titile bar image (the top-left most icon) in WPF?

6条回答
  •  Happy的楠姐
    2020-12-14 15:24

    The Icon attribute of Window is used to set Icon of a window.

    
    

    The Icon property of Window class represents a window's icon at run-time. This property takes an ImageSource variable.

    The following code snippet uses BitmapFrame.Create method to create an ImageSource and sets the Icon property of a Window.

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

    You can read more from here

提交回复
热议问题