WPF binding to My.Settings for radiobuttons (using vb.net)

Following the advice at WPF Binding My.Settings collection to Combobox items

I was able to get binding working for checkboxes but not for radiobuttons?

After saving MySettings the checkbox value is either true or false depending on if the checkbox is checked or not (as expected), while the radiobutton always returns true.

Any insights into what I am doing wrong, or is this a bug?

(ps: I have found a work around, but ...)

 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>

Settings are as they should be, correct capitalization, all boolean all user scope with default value of true or false as needed


Here, for the benefit of others, is the work around I applied:

Private Sub rbDockLeft_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles 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) Handles rbDockLeft.Unchecked

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

End Sub

链接地址: http://www.djcxy.com/p/44662.html

上一篇: 在TextBlock中使用绑定对文本进行硬编码

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