WPF:从当前程序集动态加载图像

时间:2010-01-25 23:24:56

标签: wpf image

这是我的XAML

<Image Name="StatusImage" Source="/Foo.Bar.Sam;component/Images/YellowDot.png" Stretch="Fill" MaxWidth="12" MaxHeight="12">

使用VB或C#,如何将Image更改为RedDot或GreenDot?

1 个答案:

答案 0 :(得分:2)

代码来自answer to this question

string strUri2 = String.Format(@"pack://application:,,,/MyAseemby;component/resources/main titles/{0}", CurrenSelection.TitleImage);
imgTitle.Source = new BitmapImage(new Uri(strUri2));