我正在努力解决这个问题?在我的虚拟机中nullable bool
,我有一个要绑定到 Yes/No( true/false )的属性RadRadioButton
。有人可以指出我正确的方向吗?
虚拟机
public bool? IsSDS { get; set; }
看法
<telerik:Label Content="Self Directed Support" />
<StackPanel Orientation="Horizontal">
<telerik:RadRadioButton x:Name="SelfDirectedSupportYes" Content="Yes" />
<telerik:RadRadioButton x:Name="SelfDirectedSupportNo" Content="No" />
</StackPanel>
编辑
我认为这是有效的,但我错了。只有 Yes 具有约束力。以下是我的观点,CreateAuthView
:
<StackPanel Orientation="Horizontal" Margin="3" Grid.Column="1" Grid.Row="2">
<telerik:RadRadioButton x:Name="Authorization_SelfDirectedSupportYes" GroupName="SDS" Content="Yes" />
<telerik:RadRadioButton x:Name="Authorization_SelfDirectedSupportNo" GroupName="SDS" Content="No" />
</StackPanel>
这是我的 ViewModel 上的相应部分CreateAuthViewModel
:
public Authorization Authorization
{
get
{
return this.authorization;
}
set
{
if (authorization != value)
{
this.authorization = value;
NotifyOfPropertyChange(() => Authorization);
}
}
}
最后是我模型上的属性Authorization
:
public bool? SelfDirectedSupportYes
{
get
{
return this.selfDirectedIndicator;
}
set
{
this.selfDirectedIndicator = value;
this.OnPropertyChanged();
}
}