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

Separator Style

3 Answers 53 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Don
Top achievements
Rank 1
Don asked on 07 Oct 2011, 09:01 PM
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">

3 Answers, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 10 Oct 2011, 07:23 AM
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 >>
0
Don
Top achievements
Rank 1
answered on 10 Oct 2011, 09:11 PM
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.
0
Pana
Telerik team
answered on 14 Oct 2011, 02:40 PM
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 >>
Tags
Menu
Asked by
Don
Top achievements
Rank 1
Answers by
Pana
Telerik team
Don
Top achievements
Rank 1
Share this question
or