我想改变我的按钮的背景图像其他一些图像,我遇到了一些错误。 这是我对我的XAML代码:如何在C#WPF代码中更改设置按钮的背景图像?
<Button x:Name="Button1" Width="200" Height="200" Content="Button1" Margin="0,0,0,400">
<Button.Background>
<ImageBrush **ImageSource ="Images/AERO.png"** ></ImageBrush>
</Button.Background>
</Button>
和我的CS:
private void Button1_Click_1(object sender, RoutedEventArgs e)
{
var brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("Images/AERO.png"));
Button1.Background = brush;
}
我有我的XAML中的错误是“文件‘图片\ logo.png’不是一部分 任何人都可以帮我解释一下,谢谢
你能否证实在Visual Studio项目文件“图像\ logo.png”是否被incuded。如果是,您是否也可以在其属性选项卡上确认其生成操作已设置为资源? – Kohanz 2013-04-09 02:36:10
我该如何设置Build Action属性?我似乎无法找到它。该文件 – Jaz 2013-04-09 02:41:43
单击鼠标右键,选择属性 – Kohanz 2013-04-09 02:43:17