我无法将两个radiobutton绑定到我的xaml表单和IsChecked属性,具有相同的组名,我也使用了nullabletoboolconverters.然而,我的代码中的radiobuttons缺血特性没有改变(一旦我们在第二个之后击中第一个放射性按钮,它根本没有达到断点)并且我正在绑定其中两个的缺血性质,因为我需要设置基于radiobuttons属性的表单上其他面板的可见性.
以下是我的xaml代码,后来是我的viewmodel.cs radiobutton属性代码:
<RadiobuttonSelectedConverter x:Key="CheckedSelection"/>// declaring my converter class in my resource dictionary.
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="3" Margin="10,5,0,0">
<RadioButton GroupName="RadiosGroup" IsChecked="{Binding IsRadioButton1,Mode=TwoWay,
Converter={StaticResource CheckedSelection}, ConverterParameter=true}">
First</RadioButton>
<RadioButton GroupName="RadiosGroup"
Margin="40,0,0,0" IsChecked="{Binding IsRadioButton2,Mode=TwoWay,
Converter={StaticResource CheckedSelection}, ConverterParameter=true}">Second</RadioButton>
</StackPanel>
private bool _isRadioButton1;
public bool IsRadioButton1
{
get
{
return _isRadioButton1;
}
set
{
if _isRadioButton1!= value)
{
_isRadioButton1= value;
IsRadioButton2= false;
OnPropertyChanged("IsRadioButton1");
}
}
}
private bool _isRadioButton2;
public bool IsRadioButton2
{
get
{
return _isRadioButton2;
}
set
{
if (_isRadioButton2 != value)
{ …Run Code Online (Sandbox Code Playgroud)