This question is locked. New answers and comments are not allowed.
I've got a RadMenuItem bound to a list of items which has always at least one item. What I need to do is to hide the popup in case the list has exactly one item. In all other cases I want to show it.
Since I need to customize the RadMenuItems control template anyway, I tried to solve this problem via binding in the control template.
First I've bound the popup element's visibility against the observable item collection with a converter in between that returned "Collapsed" when the count was less than 2. However this didn't work because my popup is wrapped in a Telerik specific PopupWrapper which is still visible then.
So I tried to bind the popup's horizontal offset with a converter that moves the whole stuff out of view if necessary (see snippet below). This doesn't work either because horizontal offset is just read once when creating the PopupWrapper. However, when my items collections changes dynamically from 2 items to 1, my popup element gets the desired negative offset but not the wrapper. In the end the popup is still visible. So this does not work either.
Any ideas on how to do this. I don't think I'm the first one with this scenario...
Regards,
Stephan
Since I need to customize the RadMenuItems control template anyway, I tried to solve this problem via binding in the control template.
First I've bound the popup element's visibility against the observable item collection with a converter in between that returned "Collapsed" when the count was less than 2. However this didn't work because my popup is wrapped in a Telerik specific PopupWrapper which is still visible then.
So I tried to bind the popup's horizontal offset with a converter that moves the whole stuff out of view if necessary (see snippet below). This doesn't work either because horizontal offset is just read once when creating the PopupWrapper. However, when my items collections changes dynamically from 2 items to 1, my popup element gets the desired negative offset but not the wrapper. In the end the popup is still visible. So this does not work either.
<
ControlTemplate
x:Key
=
"TopMenuItemControlTemplate"
>
...
<
Telerik:Popup
x:Name
=
"PART_Popup"
HorizontalOffset
=
"-6"
VerticalOffset
=
"{Binding Items.Count, Converter={StaticResource CountToOffsetConverter}}"
>
<
Grid
>
...
</
Grid
>
</
Telerik:Popup
>
</
ControlTemplate
>
<
Telerik:RadMenuItem
ItemsSource
=
"{Binding Items}"
Telerik:RadMenuItem.TopLevelHeaderTemplateKey
=
"{StaticResource TopMenuItemControlTemplate}"
/>
Any ideas on how to do this. I don't think I'm the first one with this scenario...
Regards,
Stephan