我正在設置要基於Radioboxes的選擇啓用組合框。目前它在下面的代碼中產生這個錯誤Object reference not set to an instance of an object.
。我一次只做一個,並使ComboBox False工作。當我將Disc_OnChecked設置爲true時,它產生了錯誤。如果我能得到幫助繞過這個錯誤,請。單選按鈕Isenabled麻煩
private void Cont_OnChecked(object sender, RoutedEventArgs e)
{
Cf.IsEnabled = false;
}
private void Disc_OnChecked(object sender, RoutedEventArgs e)
{
Cf.IsEnabled = true;
}
XAML代碼:
<GroupBox>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Type: "></TextBlock>
<RadioButton Checked="Disc_OnChecked" GroupName="Group1" x:Name="Disc" IsChecked="true" Content="Discrete" ></RadioButton>
<RadioButton Checked="Cont_OnChecked" GroupName="Group1" x:Name="Cont" Content="Continuous"></RadioButton>
</StackPanel>
</GroupBox>
<ComboBox x:Name="Cf" Width="125" SelectedIndex="1">
<ComboBoxItem Content="Annual"></ComboBoxItem>
<ComboBoxItem Content="Semi-annual"></ComboBoxItem>
</ComboBox>
絕對完美謝謝! – Master
如果它解決了您的問題,請不要忘記標記爲答案。乾杯。 –