Menu item inside menu item

2 posts, 0 answers
  1. Licensing
    Licensing avatar
    31 posts
    Member since:
    Sep 2011

    Posted 03 Oct 2011 Link to this post

    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.
  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 04 Oct 2011 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top