This is a migrated thread and some comments may be shown as answers.

Menu item inside menu item

1 Answer 207 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Licensing
Top achievements
Rank 1
Licensing asked on 03 Oct 2011, 10:42 AM
Hello!

I'm creating menu using DataBing. For some reason RadMenuItem is wrapped with other menu item. Here is how my XAML looks like:

        <telerikNavigation:RadMenuItem ItemsSource="{Binding SupportedThemes}" >
........
          <telerikNavigation:RadMenuItem.ItemTemplate>
            <DataTemplate>
              <telerikNavigation:RadMenuItem
                Header="{Binding DisplayName}"
                Command="{Binding ChangeThemeCommand}"
                CommandParameter="{Binding}"
              />
            </DataTemplate>
          </telerikNavigation:RadMenuItem.ItemTemplate>

What needs to be done order to get menu item look like static menu items? Is something special need to be added to templated?

I would like to pay your attention that suggested solution need to work in WPF.

1 Answer, 1 is accepted

Sort by
0
Dani
Telerik team
answered on 04 Oct 2011, 11:16 AM
Hi Licensing,

When you set a RadMenuItem inside the ItemTemplate of RadMenu, the result will be nested RadMenuItems. Since your ItemTemplate is in fact the content template of the RadMenuItem, you need to include only elements that are part of the content of the RadMenuItem.

My supposition is that you wish to assign a different command to each RadMenuItem. If this is the case, then you do not need the ItemTemplate.

Please check the RadContextMenu FirstLook example. It contains the approach for realizing this goal. Although the example refers to RadContextMenu, the same is valid for RadMenu. Please, take into consideration the way commands are assigned to each RadMenuItem:

<telerik:RadContextMenu.ContextMenu>
            <local:ExtendedContextMenu x:Name="contextMenu">
                <telerik:RadMenuItem Header="{Binding Menu.ClickedListBoxItem, RelativeSource={RelativeSource Self}, Converter={StaticResource HeaderTitleConverter}, ConverterParameter=EnableState}" Command="{Binding EnableCommand}" CommandParameter="{Binding Menu.ClickedListBoxItem, RelativeSource={RelativeSource Self}}" />
                <telerik:RadMenuItem Header="{Binding Menu.ClickedListBoxItem, RelativeSource={RelativeSource Self}, Converter={StaticResource HeaderTitleConverter}, ConverterParameter=ZoomState}" Command="{Binding ZoomCommand}" CommandParameter="{Binding Menu.ClickedListBoxItem, RelativeSource={RelativeSource Self}}" />
                <telerik:RadMenuItem Header="{Binding CountryHeader}" Command="{Binding MapCountryCommand}" CommandParameter="{Binding Menu.ClickedListBoxItem, RelativeSource={RelativeSource Self}}" />
            </local:ExtendedContextMenu>
        </telerik:RadContextMenu.ContextMenu>

I hope this will be helpful in yoru scenario. If you have further questions, please let me know.

All the best,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Menu
Asked by
Licensing
Top achievements
Rank 1
Answers by
Dani
Telerik team
Share this question
or