RadMenuItem doesnot show seperator

2 posts, 0 answers
  1. Sanket Singhvi
    Sanket Singhvi avatar
    20 posts
    Member since:
    May 2010

    Posted 03 Mar 2011 Link to this post


    I have declared the following template in my Resource File :
    <DataTemplate x:Key="MenuItem">
                    Header="{Binding Header}"
    IsCheckable="{Binding IsCheckable}"
    IsChecked="{Binding IsChecked, Mode=TwoWay}"
    IsSeparator="{Binding IsSeparator}"
    IsEnabled="{Binding IsEnabled}"
    Command="{Binding MenuCommand}"

    ItemsSource="{Binding MenuItems}"
    ItemTemplate="{StaticResource MenuItem}">
            <telerik:RadMenuItem Header="{Binding Header}"
                                 IsCheckable="{Binding IsCheckable}"
                                 IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                 IsSeparator="{Binding IsSeparator}"
                                 IsEnabled="{Binding IsEnabled}"
                                 Command="{Binding MenuCommand}"/>

    And I am using the above resources in RadGridView as below:
                    <telerik:RadContextMenu x:Name="_gridContextMenu" 
    ItemTemplate="{StaticResource MenuItemTemplate}"
    ItemsSource="{Binding ContextMenu}">
    ContextMenu is a ObservableCollection<ContextMenuController>. 

    Now Everything seems to be working except that IsSeperator doesn't work. When IsSeperator is true for a ContextMenuController it still shows as an Item occupied more space than it is supposed to be.

    Look at the attached image and see how it shows the RadMenuItem which is nothing but a seperator.

  2. Pana
    Pana avatar
    748 posts

    Posted 08 Mar 2011 Link to this post

    Hi Sanket Singhvi,

    HierarchicalDataTemplate is a DataTemplate and not a ControlTemplate. I have no idea why are you puttin a
    inside the DataTemplates. It means that the header of the RadMenuItem will actually be another RadMenuItem. Instead you can use a Style and Bindings inside that Style. For example you can have something like:

    <Style x:Key="MenuItemBaseStyle" TargetType="telerik:RadMenuItem">
      <Setter Property="Header" Value="{Binding Content}" />
      <Setter Property="IsSeparator" Value="{Binding IsSeparator}" />
      <Setter Property="ItemsSource" Value="{Binding}" />

    And set the style as ItemContainerStyle on RadMenu or RadMenuItem.

    In the upcomming 2011.Q1 we have prepared a Tic-Tac-Toe game MVVM example that will show how you can bind Commands, Icons, Headers, ItemsSource etc. on RadMenuItem.

    All the best,
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top