<RadioButton x:Name="radioButton3" TabIndex="14" GroupName="PregnancyStatus" Content="Yes" IsChecked="{Binding PatientInfo.PregnancyStatus, Converter={StaticResource pregnancyStatusConverter}, ConverterParameter=Yes, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<RadioButton x:Name="radioButton4" TabIndex="15" GroupName="PregnancyStatus" Content="No" IsChecked="{Binding PatientInfo.PregnancyStatus, Converter={StaticResource pregnancyStatusConverter}, ConverterParameter=No, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center" />
<RadioButton x:Name="radioButton5" TabIndex="16" GroupName="PregnancyStatus" Content="Unknown" IsChecked="{Binding PatientInfo.PregnancyStatus, Converter={StaticResource pregnancyStatusConverter}, ConverterParameter=Unknown, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
如果性别单选按钮为“女性”,如何启用此单选按钮,对于“男性”,我应该无法编辑此按钮。
答案 0 :(得分:0)
您可以使用IsEnabled
属性。我们假设您的女性性别单选按钮的x:Name
为radioFemale
。然后,您将添加IsEnabled
属性绑定,如下所示:
IsEnabled="{Binding IsChecked, ElementName=radioFemale}"
这意味着一旦选中女性单选按钮,启用属性将为true,反之亦然。所以对于你的代码:
<RadioButton x:Name="radioButton3"
IsEnabled="{Binding IsChecked, ElementName=radioFemale}"
TabIndex="14" GroupName="PregnancyStatus" Content="Yes"
IsChecked="{Binding PatientInfo.PregnancyStatus, Converter={StaticResource pregnancyStatusConverter}, ConverterParameter=Yes, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<RadioButton x:Name="radioButton4"
IsEnabled="{Binding IsChecked, ElementName=radioFemale}"
TabIndex="15" GroupName="PregnancyStatus" Content="No"
IsChecked="{Binding PatientInfo.PregnancyStatus, Converter={StaticResource pregnancyStatusConverter}, ConverterParameter=No, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding PregnancyStatusCommand}" />
<RadioButton x:Name="radioButton5"
IsEnabled="{Binding IsChecked, ElementName=radioFemale}"
TabIndex="16" GroupName="PregnancyStatus" Content="Unknown"
IsChecked="{Binding PatientInfo.PregnancyStatus, Converter={StaticResource pregnancyStatusConverter}, ConverterParameter=Unknown, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>