如何以编程方式将C#中的Image Source设置为XAML Static Resource? [英] How to set Image Source in C# to XAML Static Resource programmatically?
本文介绍了如何以编程方式将C#中的Image Source设置为XAML Static Resource?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以编程方式将C#中的图像源设置为XAML静态资源?
解决方案
如果资源是在窗口中定义的,则窗口类的资源 [ ^ ]属性哪个可以使用。
所以尝试类似
myImageControl.Source =(System.Windows.Media。 ImageSource) this .Resources [ MyResourceName];
How to set Image Source in C# to XAML Static Resource programmatically?
解决方案
If the resources are defined in a window, the window class has Resources[^] property which can be used.
So try something like
myImageControl.Source = (System.Windows.Media.ImageSource)this.Resources["MyResourceName"];
这篇关于如何以编程方式将C#中的Image Source设置为XAML Static Resource?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文