我有两个单选按钮,如果我将属性IsChecked
放在 XAML 中,程序会因 System.NullReferenceException 而崩溃。附加信息:对象引用未设置为对象的实例。
我的单选按钮:
<RadioButton IsChecked="True" Name="Mint" Checked="Mint_Checked_1"
Foreground="Red" FlowDirection="RightToLeft" VerticalAlignment="Top"
HorizontalAlignment="Right" Margin="10,30,10,0" GroupName="Update_When"
Content="A">
</RadioButton>
<RadioButton IsChecked="False" Name="Changet" Checked="Changet_Checked_1"
FlowDirection="RightToLeft" VerticalAlignment="Top" HorizontalAlignment="Right"
Margin="10,53,10,0" GroupName="Update_When" Content="B">
</RadioButton>
我的事件代码:
private void Mint_Checked_1(object sender, RoutedEventArgs e)
{
Mint.Foreground = Brushes.Red;
Changet.Foreground = Brushes.Black;
}
private void Changet_Checked_1(object sender, RoutedEventArgs e)
{
Mint.Foreground = Brushes.Black;
Changet.Foreground = Brushes.Red;
}