如何在WPF中的代码后面设置窗口图标? [英] How to set window icon in code behind in wpf?

查看:327
本文介绍了如何在WPF中的代码后面设置窗口图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在xaml中是:

  <View:BaseWindow.Icon>
    /VBDAdvertisement;component/Images/logoVBD.png
  </View:BaseWindow.Icon>

我想将其转换为后面的代码。

I want to convert it into code behind.

谢谢

推荐答案

类似

myWindow.Icon = new BitmapImage(new Uri("/VBDAdvertisement;component/Images/logoVBD.png"));

您可能需要进一步限定路径。

You may need to qualify the path more though.

编辑:我认为路径应位于 pack-uri 格式:

As i thought the path should be in pack-uri format:

"pack://application:,,,/VBDAdvertisement;component/Images/logoVBD.png"

这篇关于如何在WPF中的代码后面设置窗口图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆