C#选择radioBox1和radioBox2更换groupBox2的背景图片,明明在资源项目文件里有这个图片,
但是一直提示
错误 CS1061 “object”未包含“Ub”的定义,并且找不到可接受第一个“object”类型参数的可访问扩展方法“Ub”(是否缺少 using 指令或程序集引用?)
<RadioButton Name="RadioBox1" Content="Option 1" Checked="RadioBox_Checked"/>
<RadioButton Name="RadioBox2" Content="Option 2" Checked="RadioBox_Checked"/>
<GroupBox Name="GroupBox2" Background="White">
<GroupBox.Background>
<ImageBrush ImageSource="Ua.png"/>
</GroupBox.Background>
</GroupBox>
private void RadioBox_Checked(object sender, RoutedEventArgs e)
{
if (RadioBox1.IsChecked == true)
{
GroupBox2.Background = new ImageBrush(new BitmapImage(new Uri("Ua.png", UriKind.Relative)));
}
else if (RadioBox2.IsChecked == true)
{
GroupBox2.Background = new ImageBrush(new BitmapImage(new Uri("Ub.png", UriKind.Relative)));
}
}