How to set window icon in code behind in wpf?
问题 In xaml it is : <View:BaseWindow.Icon> /VBDAdvertisement;component/Images/logoVBD.png </View:BaseWindow.Icon> I want to convert it into code behind. Thanks 回答1: Something like myWindow.Icon = new BitmapImage(new Uri("/VBDAdvertisement;component/Images/logoVBD.png")); You may need to qualify the path more though. Edit: As i thought the path should be in pack-uri format: "pack://application:,,,/VBDAdvertisement;component/Images/logoVBD.png" 回答2: Try this its absolutely working for both png as