views:

898

answers:

2

Following the advice at http://stackoverflow.com/questions/204779/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

+1  A: 

Hi, check geeks with blogs advice

Ric Tokyo
Thank you, at least now I know its a known problem; I have applied another work around that will be quicker to pull if/when Microsoft fixes this. Code to follow in next post (as I don't have enough room here).
Rob
A: 

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

Rob