我将尝试更改按钮的背景图像为其他图像,但是遇到了一些错误。 这是我的XAML代码:
<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>
我的计算机科学:
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中遇到的错误是“文件'Images\logo.png'不是该项目的一部分,或者它的'Build Action'属性未设置为'Resource'。请问有谁能帮我解释一下吗?谢谢。