Hello,
I am trying to simulate radio button behavior in a RadMenu. I thought it would be possible to simply have some hidden RadioButtons on my page and ElementBind the "IsChecked" property of the RadMenuItem to the RadioButton.
And actually, it works!
And then I tried to switch to a RadContextMenu and it stops working. I am assuming that it has something to do with the DataContext possibly but am not sure. I tried setting the "InheritDataContext" property and it did not seem to help.
I've attached a code sample below...
I am trying to simulate radio button behavior in a RadMenu. I thought it would be possible to simply have some hidden RadioButtons on my page and ElementBind the "IsChecked" property of the RadMenuItem to the RadioButton.
And actually, it works!
And then I tried to switch to a RadContextMenu and it stops working. I am assuming that it has something to do with the DataContext possibly but am not sure. I tried setting the "InheritDataContext" property and it did not seem to help.
I've attached a code sample below...
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
StackPanel
Orientation
=
"Vertical"
>
<
RadioButton
x:Name
=
"opt1"
Content
=
"Option1"
IsChecked
=
"True"
GroupName
=
"grp1"
/>
<
RadioButton
x:Name
=
"opt2"
Content
=
"Option2"
IsChecked
=
"False"
GroupName
=
"grp1"
/>
</
StackPanel
>
<
ToggleButton
Width
=
"40"
Height
=
"40"
Content
=
"^"
IsChecked
=
"{Binding IsOpen, ElementName=rcm, Mode=TwoWay}"
>
<
RadNav:RadContextMenu.ContextMenu
>
<
RadNav:RadContextMenu
x:Name
=
"rcm"
Placement
=
"Bottom"
InheritDataContext
=
"True"
>
<
RadNav:RadMenuItem
Header
=
"Option1"
IsCheckable
=
"True"
IsChecked
=
"{Binding IsChecked, ElementName=opt1, Mode=TwoWay}"
/>
<
RadNav:RadMenuItem
Header
=
"Option2"
IsCheckable
=
"True"
IsChecked
=
"{Binding IsChecked, ElementName=opt2, Mode=TwoWay}"
/>
</
RadNav:RadContextMenu
>
</
RadNav:RadContextMenu.ContextMenu
>
</
ToggleButton
>
<
RadNav:RadMenu
>
<
RadNav:RadMenuItem
Header
=
"^"
>
<
RadNav:RadMenuItem
Header
=
"Option1"
IsCheckable
=
"True"
IsChecked
=
"{Binding IsChecked, ElementName=opt1, Mode=TwoWay}"
/>
<
RadNav:RadMenuItem
Header
=
"Option2"
IsCheckable
=
"True"
IsChecked
=
"{Binding IsChecked, ElementName=opt2, Mode=TwoWay}"
/>
</
RadNav:RadMenuItem
>
</
RadNav:RadMenu
>
</
StackPanel
>
</
Grid
>