Wpf 将窗口图标绑定到图像
好的,我有一个自定义窗口控件。我试图做的是设置Wpf 将窗口图标绑定到图像,wpf,image,window,Wpf,Image,Window,好的,我有一个自定义窗口控件。我试图做的是设置图像控件,并试图将.Source设置为窗口.Icon属性 我所拥有的是 public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof (ImageSource), typeof (OctgnChrome)); private Image IconImage { get; set; } 在构造函
图像
控件,并试图将.Source
设置为窗口.Icon
属性
我所拥有的是
public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof (ImageSource), typeof (OctgnChrome));
private Image IconImage { get; set; }
在构造函数中
IconImage.SetBinding(IconProperty, new Binding("Icon") {UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged});
octgncrome是自定义窗口的名称
问题是窗口有一个图标,当我运行时它会显示在任务栏上,但是图像
没有显示任何内容,只是空白
关于如何解决这个问题,或者我可能做错了什么,有什么想法吗
阿尔索
如果我将其设置为直接指向某个图标,它就会工作,如下所示
IconImage = new Image{Source = new BitmapImage(new Uri("pack://application:,,,/Octgn;component/Resources/Icon.ico")) };
我可以看到三个问题
Icon
,而不是IconImage
Image
vsImageSource
)IconImage
属性:
public ImageSource Icon
{
get { return this.GetValue(IconProperty) as ImageSource; }
set { this.SetValue(IconProperty, value); }
}
请不要在标题中添加不必要的杂乱内容。平台/技术信息已经通过标签传达,我猜大多数想回答问题的人都是通过标签浏览的,所以他们确切地知道他们当前看到的问题是关于什么的。