Separator Style

4 posts, 0 answers
  1. Don
    Don avatar
    40 posts
    Member since:
    Apr 2009

    Posted 07 Oct 2011 Link to this post

    I am trying to get a separator to display a brey bar and cannot get it to do so. I set up a style and assigned it to the menu but for some reason the separators of the menu do not pick up the style. How would I do this?

    Here it the style:

    <Style x:Key="MenuItemStyle1" TargetType="telerikNavigation:RadMenuItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Padding" Value="4,3,2,3"/>
        <Setter Property="SeparatorTemplateKey">
            <Setter.Value>
                <ControlTemplate x:Key="SeparatorTemplate" TargetType="telerikNavigation:RadMenuItem">
                    <Grid Height="10" Margin="0, 3, 0, 0">
                        <Rectangle Fill="Red" Height="5" VerticalAlignment="Top"/>
                        <Rectangle Fill="Green" Height="5" VerticalAlignment="Bottom"/>
                    </Grid>
                </ControlTemplate>
     
            </Setter.Value>
        </Setter>
    </Style>

    And here is the assignment

    <telerikNavigation:RadContextMenu
    x:Name="DesignerContextMenu"
    ItemClick="DesignerContextMenuClick"
    Opened="DesignerContextMenuOpened"  ItemContainerStyle="{StaticResource MenuItemStyle1}"
    Margin="0,0,0,0">
  2. Pana
    Admin
    Pana avatar
    748 posts

    Posted 10 Oct 2011 Link to this post

    Hello Don,

    Do you set ItemsSource on the RadContextMenu or you inline items in xaml? If you inline the items set the Style in the Style property of the RadMenuItem separator.

    Greetings,
    Pana
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
  4. Don
    Don avatar
    40 posts
    Member since:
    Apr 2009

    Posted 10 Oct 2011 Link to this post

    I've tried every way I can come up with tho do that. Can you give me an example of how to set that inline in the XAML.
  5. Pana
    Admin
    Pana avatar
    748 posts

    Posted 14 Oct 2011 Link to this post

    Hello Don,

    Set it like that:

    <UserControl x:Class="RadMenuSeparator.MainPage"
            mc:Ignorable="d"
            d:DesignHeight="300" d:DesignWidth="400">
          
        <UserControl.Resources>
            <ControlTemplate x:Key="RadMenuItemSeparatorStyle" TargetType="telerik:RadMenuItem">
                <Grid>
                    <Rectangle Height="2" Fill="Red" />
                </Grid>
            </ControlTemplate>
            <Style x:Key="SeparatorStyle" TargetType="telerik:RadMenuItem">
                <Setter Property="SeparatorTemplateKey" Value="{StaticResource RadMenuItemSeparatorStyle}" />
            </Style>
        </UserControl.Resources>
      
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadMenu VerticalAlignment="Top">
                <telerik:RadMenuItem Header="File">
                    <telerik:RadMenuItem Header="Open" />
                    <telerik:RadMenuItem Header="Save" />
                    <telerik:RadMenuItem Header="Save As" />
                    <telerik:RadMenuItem Header="Close" />
                    <telerik:RadMenuItem IsSeparator="True" Style="{StaticResource SeparatorStyle}" />
                    <telerik:RadMenuItem Header="Exit" />
                </telerik:RadMenuItem>
            </telerik:RadMenu>
        </Grid>
    </UserControl>


    All the best,
    Pana
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top