WPF绑定到My.Settings的单选按钮(使用vb.net)

时间:2009-01-27 01:49:48

标签: wpf binding checkbox radio-button

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

我能够为复选框获取绑定工作但不能用于无线电按钮吗?

保存MySettings后 复选框值为true或false,具体取决于是否选中了复选框(如预期的那样),而radiobutton始终返回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根据需要

1 个答案:

答案 0 :(得分: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

End Sub

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

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

End Sub