【发布时间】:2016-08-14 12:19:48
【问题描述】:
我在我的 Xaml 编辑器中添加了一个图像(image1),将源属性更改为 Source="/WpfApplication9;component/Images/a.png"
我有一个按钮, 我想要的是,如果我单击该按钮,我希望我的 image1 更改其来源。 我已经使用了这段代码,但是当我单击按钮时,具有“a.png”的 image1 什么也没有,或者没有显示任何内容。
这是我的代码
private void button1_Click(object sender, RoutedEventArgs e)
{
image1.Source = (System.Windows.Media.ImageSource)this.Resources["/Resources/a.png"];
}
这是我的 xaml
<Image Height="150" HorizontalAlignment="Left" Margin="153,56,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="200" Source="/WpfApplication9;component/Images/a.png" />
【问题讨论】: