I got a very simple user control (visifire charts + datepickers and some radiobuttons to control filtering etc):
<GroupBox Header="Scale" Width="159" HorizontalAlignment="Left" Margin="10,47,0,0"
Height="38" VerticalAlignment="Top" Name="scalingBox">
<Canvas Height="16">
<RadioButton Name="scaleDays" Content="Days" GroupName="g2" Width="47"
IsChecked="True" Checked="scale_Change"/>
<RadioButton Name="scaleHours" Content="Hours" GroupName="g2" Canvas.Left="60"
Width="59" Checked="scale_Change"/>
</Canvas>
</GroupBox>
First bit is that setting IsChecked
to true on the first button doesn't do anything when the control is displayed.
Searching for a workaround I exposed some public methods to check the buttons I want from the parent window, but when I have more than one MyControl
calling these methods only checks the buttons on one instance where the methods was last called. like this:
myControl1.SetDefaultScale();
myControl2.SetDefaultScale();
only checks the buttons on myControl2
, leaving all the buttons in the group unchecked on myControl1
.
Any ideas what may be causing this?
And yes, it was the group name that got shared among all the controls... Thanks Aran
i got your code, put it in a new project and on the main window. and the first button came up checked.
RadioButtons have some bugs, first they lose their bindings if you click on them see here. I have had the behaviour you describe where group names are shared between forms, as have some other people. how i get around these issues is to bind each radio button seperately and handle the selection logic myself. (if one is selected set the properties that the others in the 'group' are binding to to be false)
im hoping it gets fixed in the next release. but for the meantime i bind every radio button seperately and dont use group names.