0

遵循 WPF Binding My.Settings collection to Combobox items的建议

我能够为复选框绑定工作,但不能为单选按钮工作?

保存 MySettings 后,复选框值是 true 还是 false,具体取决于复选框是否被选中(如预期的那样),而单选按钮始终返回 true。

对我做错了什么有任何见解,或者这是一个错误?

(ps:我找到了解决方法,但是...)

 xmlns:self="clr-namespace:myprog"  






                    <CheckBox     Name="cbStartDocked"     IsChecked="{Binding Source={x:Static self:MySettings.Default}, Path=StartDocked}" Margin="8,0,20.706,39" Height="21" VerticalAlignment="Bottom">Start doc_ked</CheckBox>
                    <RadioButton  Name="rbDockLeft"        IsChecked="{Binding Source={x:Static self:MySettings.Default}, Path=DockLeft}"    Margin="25,0,24,24" Height="16" VerticalAlignment="Bottom">Dock _left</RadioButton>
                    <RadioButton  Name="rbDockRight"       IsChecked="{Binding Source={x:Static self:MySettings.Default}, Path=DockRight}"   Margin="25,0,33,2" Height="16" VerticalAlignment="Bottom">Dock _right</RadioButton>

设置应该是正确的大小写,所有布尔值所有用户范围,根据需要默认值为 true 或 false

4

1 回答 1

0

为了他人的利益,这里是我应用的工作:

Private Sub rbDockLeft_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) 处理 rbDockLeft.Checked

    My.Settings.DockLeft = True
    My.Settings.DockRight = False

结束子

Private Sub rbDockLeft_Unchecked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) 处理 rbDockLeft.Unchecked

    My.Settings.DockLeft = False
    My.Settings.DockRight = True

结束子

于 2009-01-27T22:43:06.920 回答