RadContextMenu : Change background color on mouse hover

8 posts, 0 answers
  1. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 07 Aug 2013 Link to this post

    Hello,

    I have created a RadContextMenu like below:
    <telerik:RadContextMenu.ContextMenu>
                   <telerik:RadContextMenu x:Name="cntxtMenu" ItemClick="ContextMenu_ItemClicked" Style="{StaticResource ContextMenuStyle}">
                       <telerik:RadMenuItem x:Name="cmAddRuler" Header="{Binding VerticalLine_AddAnchorRuler, Source={StaticResource myCultureResource}}" Visibility="Visible" />
                       <telerik:RadMenuItem x:Name="cmRemoveRuler" Header="{Binding VerticalLine_RemoveRuler, Source={StaticResource myCultureResource}}" Visibility="Visible" IsEnabled="False" />
                       <telerik:RadMenuItem x:Name="cmShowTrackball" Header="{Binding VerticalLine_ShowTrackball, Source={StaticResource myCultureResource}}" Visibility="Collapsed" />
                       <telerik:RadMenuItem x:Name="cmHideTrackball" Header="{Binding VerticalLine_HideTrackball, Source={StaticResource myCultureResource}}" Visibility="Visible" />
                       <telerik:RadMenuItem x:Name="cmShowMarkers" Header="{Binding VerticalLine_ShowMarkers, Source={StaticResource myCultureResource}}" Visibility="Visible" />
                       <telerik:RadMenuItem x:Name="cmHideMarkers" Header="{Binding VerticalLine_HideMarkers, Source={StaticResource myCultureResource}}" Visibility="Collapsed" />
                       <telerik:RadMenuItem x:Name="cmShowMarkersWithLabels" Header="{Binding VerticalLine_ShowMarkersWithLabels, Source={StaticResource myCultureResource}}" Visibility="Visible" />
                       <telerik:RadMenuItem x:Name="cmHideMarkersWithLabels" Header="{Binding VerticalLine_HideMarkersWithLabels, Source={StaticResource myCultureResource}}" Visibility="Collapsed" />
                   </telerik:RadContextMenu>
               </telerik:RadContextMenu.ContextMenu>

    And the following style:

    <Style TargetType="telerik:RadMenuItem">
            <Setter Property="IsSeparator" Value="False" />
            <Setter Property="Padding" Value="{StaticResource MenuItemPadding}" />
            <Setter Property="Background" Value="{StaticResource tooltip}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Foreground" Value="{StaticResource largeText}" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
        </Style>
     
        <Style x:Key="ContextMenuStyle" TargetType="telerik:RadContextMenu">
            <Setter Property="Foreground" Value="{StaticResource largeText}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="telerik:RadContextMenu">
                        <Border CornerRadius="0" BorderBrush="{StaticResource smallText}" BorderThickness="1" Background="{StaticResource tooltip}" Padding="0 0 0 0" Margin="0" >
                            <ItemsPresenter />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    I have also tried including the below in the style but was not able to change the mouse over color of radmenuitem

    <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource TopLevelHeaderTemplate}" />
    <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource TopLevelItemTemplate}" />
    <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource SubMenuHeaderTemplate}" />
    <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource SubMenuItemTemplate}" />
    <Setter Property="SeparatorTemplateKey" Value="{StaticResource SeparatorTemplate}" />

    I am using the latest Telerik Q2 2013 version of silverlight

    I am showing the radcontextmenu in the RadCartesianChart and want to change the hover color 

    Please send me a solution where you have used RadContextMenu like in the pic attached.

    It is very urgent. Please reply asap.

    Thanks,
    Nitin
  2. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 08 Aug 2013 Link to this post

    Can somebody pls reply to my query. It is a very high priority issue for me.

    Thanks,
    Nitin 
  3. DevCraft banner
  4. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 08 Aug 2013 Link to this post

    Hi Nitin,

    I'm sending you a sample project, demonstrating how to achieve this. Please check the App.xaml file, where I've inserted RadMenuItem's implicit style from our OfficeBlack theme. You'll find out the brushes I've changed in the file.

    Hopefully this helps. Feel free to contact us in case you have any problems or concerns.

    Regards,
    Rosen Vladimirov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 08 Aug 2013 Link to this post

    Hi Rosen,

    I tried to run your solution (Visual Studio 2012) which gave me build errors. Can you please check the attachment.

    Error 1 The name "SharedSizeContentPresenter" does not exist in the namespace "http://schemas.telerik.com/2008/xaml/presentation".

    Error 2 The name "SharedSizeScope" does not exist in the namespace "http://schemas.telerik.com/2008/xaml/presentation".

    Error 3 The tag 'SharedSizeContentPresenter' does not exist in XML namespace 'http://schemas.telerik.com/2008/xaml/presentation'.

    Error 4 The property 'IsSharedSizeScope' does not exist on the type 'ScrollViewer' in the XML namespace


    Thanks.



  6. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 08 Aug 2013 Link to this post

    Hello Nitin,

    I'm sending my project again. I've also included a short video, demonstrating that everything works on my side. Maybe there is a difference in the controls version - I've used 2013.2 724.

    Hopefully this helps. Feel free to contact us in case you have any problems or concerns.

    Regards,
    Rosen Vladimirov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  7. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 08 Aug 2013 Link to this post

    Thanks Rosen.

    Your solution is working now. I will implement it in my code.

    Also how can I remove the blank space on the left hand side of the radmenuitem for icons

    I want my text to aligned on the left ..dont want the seperator which is currently there..
    Please check attached image

    Thanks,
    Nitin R
  8. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 08 Aug 2013 Link to this post

    Hi Rosen,

    After integrating, it is giving build errors.

    I checked my telerik dll version and it is 2013.2.611.1050

    can you please check ?

    <ResourceDictionary
        xmlns:System="clr-namespace:System;assembly=mscorlib"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"

        xmlns:telerikChromes="clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls"
    >

     
        <SolidColorBrush x:Key="MenuScrollButtonBackground" Color="#FFDEDEDE" />
     
        <SolidColorBrush x:Key="MenuScrollButtonBorderBrush" Color="#FFFFFFFF" />
        <SolidColorBrush x:Key="MenuIconForeground_Normal" Color="#FF000000" />
        <SolidColorBrush x:Key="MenuIconBackground_Normal" Color="#FFFFFFFF" />
        <SolidColorBrush x:Key="MenuIconForeground_MouseOver" Color="#FF000000" />
        <SolidColorBrush x:Key="MenuIconBackground_MouseOver" Color="#FFFFFFFF" />
        <CornerRadius x:Key="SplitButton_SpanInnerCornerRadius">0</CornerRadius>
        <SolidColorBrush x:Key="MenuItemBorderBrush" Color="#FF848484" />
        <SolidColorBrush x:Key="MenuPopupBorderBrush" Color="#FF848484" />
        <SolidColorBrush x:Key="MenuPopupBackground" Color="#FFFFFFFF" />
        <SolidColorBrush x:Key="MenuItemSeparatorTop" Color="#FF848484" />
        <SolidColorBrush x:Key="MenuItemSeparatorBottom" Color="Transparent" />
        <SolidColorBrush x:Key="MenuItemSeparatorLeft" Color="#FF848484" />
        <SolidColorBrush x:Key="MenuItemSeparatorRight" Color="Transparent" />
        <SolidColorBrush x:Key="MenuIconColumnBackground" Color="#FFF0F0F0" />
        <SolidColorBrush x:Key="MenuIconColumnBorderBrush" Color="#FF848484" />
        <Thickness x:Key="MenuItemPadding">6 3</Thickness>
        <LinearGradientBrush x:Key="ControlOuterBorder_Pressed" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FF282828" />
            <GradientStop Color="#FF5F5F5F" Offset="1" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="ControlBackground_Pressed" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFFFDCAB" Offset="0" />
            <GradientStop Color="#FFFFD18F" Offset="0.5" />
            <GradientStop Color="#FFFE9227" Offset="0.5" />
            <GradientStop Color="#FFFFBA74" Offset="0" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="ControlInnerBorder_Pressed" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFB69A78" />
            <GradientStop Color="#FFFFE17A" Offset="0.126" />
        </LinearGradientBrush>
        <CornerRadius x:Key="SplitButton_SpanCornerRadius">1</CornerRadius>
     
        <!--NOTE: Change this brushes to control the highlighted (mouse over) color-->
        <SolidColorBrush x:Key="ControlOuterBorder_Highlighted" Color="Green" />
        <LinearGradientBrush x:Key="ControlBackground_Highlighted" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Green" Offset="0" />
            <GradientStop Color="Green" Offset="1" />
        </LinearGradientBrush>
        <SolidColorBrush x:Key="ControlInnerBorder_Highlighted" Color="#FFFFFFFF" />
        <Style x:Key="MenuScrollButton" TargetType="RepeatButton">
            <Setter Property="Interval" Value="50" />
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="MinWidth" Value="0" />
            <Setter Property="MinHeight" Value="0" />
            <Setter Property="Background" Value="{StaticResource MenuScrollButtonBackground}" />
            <Setter Property="BorderBrush" Value="{StaticResource MenuScrollButtonBorderBrush}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="ClickMode" Value="Hover" />
        </Style>
        <Style x:Key="MenuScrollUpButton" TargetType="RepeatButton" BasedOn="{StaticResource MenuScrollButton}">
            <Setter Property="BorderThickness" Value="0 0 0 1" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="RepeatButton">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <c:Default>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ForegroundIcon" Storyboard.TargetProperty="Fill">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuIconForeground_MouseOver}" />
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundIcon" Storyboard.TargetProperty="Fill">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuIconBackground_MouseOver}" />
                                                </ObjectAnimationUsingKeyFrames>
                                            </c:Default>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentContainer" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Thickness>1 3 1 1</Thickness>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused" />
                                    <VisualState x:Name="Unfocused" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="ContentContainer" Margin="1 2 1 2">
                                <Path x:Name="BackgroundIcon" Data="M0,4 L3.5,0.5 7,4 Z" Stretch="None" Width="7" Height="4" Fill="{StaticResource MenuIconBackground_Normal}" Margin="0 2 0 0" />
                                <Path x:Name="ForegroundIcon" Data="M0,4 L3.5,0.5 7,4 Z" Stretch="None" Width="7" Height="4" Fill="{StaticResource MenuIconForeground_Normal}" Margin="0 1 0 1" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="MenuScrollDownButton" TargetType="RepeatButton" BasedOn="{StaticResource MenuScrollButton}">
            <Setter Property="BorderThickness" Value="0 1 0 0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="RepeatButton">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <c:Default>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ForegroundIcon" Storyboard.TargetProperty="Fill">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuIconForeground_MouseOver}" />
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundIcon" Storyboard.TargetProperty="Fill">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuIconBackground_MouseOver}" />
                                                </ObjectAnimationUsingKeyFrames>
                                            </c:Default>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentContainer" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Thickness>1 3 1 1</Thickness>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused" />
                                    <VisualState x:Name="Unfocused" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="ContentContainer" Margin="1 2 1 2">
                                <Path x:Name="BackgroundIcon" Data="M0,0 L3.5,3.5 7,0 Z" Stretch="None" Width="7" Height="4" Fill="{StaticResource MenuIconBackground_Normal}" Margin="0 2 0 0" />
                                <Path x:Name="ForegroundIcon" Data="M0,0 L3.5,3.5 7,0 Z" Stretch="None" Width="7" Height="4" Fill="{StaticResource MenuIconForeground_Normal}" Margin="0 1 0 1" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="MenuScrollBar" TargetType="ScrollBar">
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ScrollBar">
                        <Grid x:Name="Root">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="VerticalRoot">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <telerikNavigationPrimitives:MenuScrollBarBehavior x:Name="MenuScrollBarAttachedBehavior" Value="{TemplateBinding Value}" Maximum="{TemplateBinding Maximum}" ViewportSize="{TemplateBinding ViewportSize}" />
                                <RepeatButton x:Name="VerticalSmallDecrease" Style="{StaticResource MenuScrollUpButton}" ClickMode="Hover" Visibility="{Binding Path=DecreaseButtonComputedVisibility, ElementName=MenuScrollBarAttachedBehavior}" />
                                <RepeatButton x:Name="VerticalSmallIncrease" Style="{StaticResource MenuScrollDownButton}" Grid.Row="2" ClickMode="Hover" Visibility="{Binding Path=IncreaseButtonComputedVisibility, ElementName=MenuScrollBarAttachedBehavior}" />
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="MenuScrollViewer" TargetType="ScrollViewer">
            <Setter Property="Padding" Value="0" />
            <Setter Property="HorizontalScrollBarVisibility" Value="Hidden" />
            <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ScrollViewer">
                        <Grid>
                            <ScrollContentPresenter Margin="{TemplateBinding Padding}" />
                            <ScrollBar x:Name="VerticalScrollBar" Orientation="Vertical" Style="{StaticResource MenuScrollBar}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Value="{TemplateBinding VerticalOffset}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="MenuItemTemplate" TargetType="telerik:RadMenuItem">
            <Grid x:Name="RootElement">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="SubMenuOpen">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="HighlightVisual" Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlBackground_Pressed}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="HighlightVisual" Storyboard.TargetProperty="BorderBrush">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlOuterBorder_Pressed}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="HighlightInnerBorderVisual" Storyboard.TargetProperty="BorderBrush">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlInnerBorder_Pressed}" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation To="1" Duration="0:0:0" Storyboard.TargetName="HighlightVisual" Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Highlighted">
                            <Storyboard>
                                <DoubleAnimation To="1" Duration="0:0:0" Storyboard.TargetName="HighlightVisual" Storyboard.TargetProperty="Opacity" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentGrid" To="0.5" Duration="0:0:0" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Normal" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Unfocused" />
                        <VisualState x:Name="Focused" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="CheckStates">
                        <VisualState x:Name="Checked">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Tick" Storyboard.TargetProperty="Visibility" Duration="0">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unchecked" />
                        <VisualState x:Name="HideIcon">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility" Duration="0">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="RoleStates">
                        <VisualState x:Name="TopLevelItem">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="IconHost" Storyboard.TargetProperty="Margin">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Thickness>-2 0 -7 0</Thickness>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="TopLevelHeader">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="IconHost" Storyboard.TargetProperty="Margin">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Thickness>-2 0 -7 0</Thickness>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="SubmenuItem" />
                        <VisualState x:Name="SubmenuHeader">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpandIcon" Storyboard.TargetProperty="Visibility" Duration="0">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Separator" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="OrientationStates">
                        <VisualState x:Name="Horizontal" />
                        <VisualState x:Name="Vertical" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="ChildrenStates">
                        <VisualState x:Name="HasChildren" />
                        <VisualState x:Name="NoChildren" />
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="HeaderStates">
                        <VisualState x:Name="VisibleHeader" />
                        <VisualState x:Name="EmptyHeader">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Margin">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Thickness>5 3 4 3</Thickness>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Visibility" Duration="0">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
                <Grid x:Name="ContentGrid" Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Border x:Name="HighlightVisual" Grid.ColumnSpan="4" Opacity="0" CornerRadius="{StaticResource SplitButton_SpanCornerRadius}" BorderThickness="1" BorderBrush="{StaticResource ControlOuterBorder_Highlighted}" Background="{StaticResource ControlBackground_Highlighted}">
                        <Border x:Name="HighlightInnerBorderVisual" BorderThickness="1" CornerRadius="{StaticResource SplitButton_SpanInnerCornerRadius}" BorderBrush="{StaticResource ControlInnerBorder_Highlighted}" />
                    </Border>
                    <Grid x:Name="IconHost" Width="{TemplateBinding IconColumnWidth}" Margin="-2 0 -1 0">
                        <Path x:Name="Tick" Margin="5 3 6 3" Visibility="Collapsed" FlowDirection="LeftToRight" Fill="{TemplateBinding Foreground}" Width="16" Height="16" Data="M 4,7.1 L 5.7,7.2 L 7.4,9.1 L 12,2.4 L 13.2,2 L 7.3,13.8 Z" />
                        <ContentPresenter x:Name="Icon" Margin="5 3 6 3" Content="{TemplateBinding Icon}" ContentTemplate="{TemplateBinding IconTemplate}" />
                    </Grid>
                    <ContentPresenter x:Name="Content" Grid.Column="1" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" />
                    <telerik:SharedSizeContentPresenter HorizontalAlignment="Right" SharedSizeGroupWidth="ExpandIconColumn" Grid.Column="2">
                        <Grid x:Name="ExpandIcon" Margin="0 0 2 0" Height="19" Width="16" Visibility="Collapsed">
                            <Path Margin="6 7 6 5" Fill="{StaticResource MenuIconBackground_Normal}" Data="M0,0 L0,7 1,7 1,6 2,6 2,5 3,5 3,4 4,4 4,3 3,3 3,2 2,2 2,1 1,1 1,0 z" />
                            <Path Margin="6 6 6 6" Fill="{StaticResource MenuIconForeground_Normal}" Data="M0,0 L0,7 1,7 1,6 2,6 2,5 3,5 3,4 4,4 4,3 3,3 3,2 2,2 2,1 1,1 1,0 z" />
                        </Grid>
                    </telerik:SharedSizeContentPresenter>
                </Grid>
                <Popup x:Name="PART_Popup" HorizontalOffset="-1" VerticalOffset="-1">
                    <Grid Width="{TemplateBinding DropDownWidth}" Height="{TemplateBinding DropDownHeight}">
                        <Grid x:Name="PopupContentElement" Margin="0 0 3 3">
                            <telerikChromes:ShadowChrome />
                            <Border BorderThickness="1" BorderBrush="{StaticResource MenuPopupBorderBrush}" Background="{StaticResource MenuPopupBackground}">
                                <Grid>
                                    <Border x:Name="IconSeparatorBackground" HorizontalAlignment="Left" BorderBrush="{StaticResource MenuIconColumnBorderBrush}" BorderThickness="0 0 1 0" Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IconColumnWidth}" Background="{StaticResource MenuIconColumnBackground}" />
                                    <ScrollViewer x:Name="PART_ScrollViewer" Style="{StaticResource MenuScrollViewer}" telerik:SharedSizeScope.IsSharedSizeScope="True">
                                        <Grid>
                                            <ItemsPresenter />
                                        </Grid>
                                    </ScrollViewer>
                                </Grid>
                            </Border>
                        </Grid>
                    </Grid>
                </Popup>
            </Grid>
        </ControlTemplate>
        <ControlTemplate x:Key="SeparatorTemplate" TargetType="telerik:RadMenuItem">
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="OrientationStates">
                        <VisualState x:Name="VerticalState" />
                        <VisualState x:Name="HorizontalState">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalSeparator" Storyboard.TargetProperty="Visibility" Duration="0">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalSeparator" Storyboard.TargetProperty="Visibility" Duration="0">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid x:Name="HorizontalSeparator">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0" HorizontalAlignment="Left" Width="{TemplateBinding IconColumnWidth}" />
                    <Grid Grid.Column="1" Height="2" Margin="4 4 4 3">
                        <Rectangle Height="1" VerticalAlignment="Top" Fill="{StaticResource MenuItemSeparatorTop}" />
                        <Rectangle Height="1" VerticalAlignment="Bottom" Fill="{StaticResource MenuItemSeparatorBottom}" />
                    </Grid>
                </Grid>
                <Grid x:Name="VerticalSeparator" Visibility="Collapsed" Width="2" Margin="2">
                    <Rectangle Width="1" HorizontalAlignment="Left" Fill="{StaticResource MenuItemSeparatorLeft}" />
                    <Rectangle Width="1" HorizontalAlignment="Right" Fill="{StaticResource MenuItemSeparatorRight}" />
                </Grid>
            </Grid>
        </ControlTemplate>
        <Style x:Key="RadMenuItemBaseStyle" TargetType="telerik:RadMenuItem">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="{StaticResource MenuItemBorderBrush}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
        </Style>
        <Style x:Key="RadMenuItemStyle" TargetType="telerik:RadMenuItem" BasedOn="{StaticResource RadMenuItemBaseStyle}">
            <Setter Property="Padding" Value="{StaticResource MenuItemPadding}" />
            <Setter Property="Template" Value="{StaticResource MenuItemTemplate}" />
            <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource MenuItemTemplate}" />
            <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource MenuItemTemplate}" />
            <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource MenuItemTemplate}" />
            <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource MenuItemTemplate}" />
            <Setter Property="SeparatorTemplateKey" Value="{StaticResource SeparatorTemplate}" />
        </Style>
        <Style TargetType="telerik:RadMenuItem" BasedOn="{StaticResource RadMenuItemStyle}" />
     
     
        <!--<Style TargetType="telerik:RadMenuItem">
            <Setter Property="IsSeparator" Value="False" />
            <Setter Property="Padding" Value="{StaticResource MenuItemPadding}" />
            <Setter Property="Background" Value="{StaticResource tooltip}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Foreground" Value="{StaticResource largeText}" />
            <Setter Property="TopLevelHeaderTemplateKey" Value="{StaticResource TopLevelHeaderTemplate}" />
            <Setter Property="TopLevelItemTemplateKey" Value="{StaticResource TopLevelItemTemplate}" />
            <Setter Property="SubmenuHeaderTemplateKey" Value="{StaticResource SubMenuHeaderTemplate}" />
            <Setter Property="SubmenuItemTemplateKey" Value="{StaticResource SubMenuItemTemplate}" />
            <Setter Property="SeparatorTemplateKey" Value="{StaticResource SeparatorTemplate}" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
        </Style>-->
     
        <Style x:Key="ContextMenuStyle" TargetType="telerik:RadContextMenu">
            <Setter Property="Foreground" Value="{StaticResource largeText}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="telerik:RadContextMenu">
                        <Border CornerRadius="0" BorderBrush="{StaticResource smallText}" BorderThickness="1" Background="{StaticResource tooltip}" Padding="0 0 0 0" Margin="0" >
                            <ItemsPresenter />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
     
    </ResourceDictionary>


    I am getting the following errors : 

    Error 2 The name "Default" does not exist in the namespace "http://schemas.telerik.com/2008/xaml/compile".
    Error 5 MenuScrollBarBehavior is not supported in a Silverlight project.
    Error 8 The name "SharedSizeContentPresenter" does not exist in the namespace "http://schemas.telerik.com/2008/xaml/presentation".
    Error 9 The name "SharedSizeScope" does not exist in the namespace "http://schemas.telerik.com/2008/xaml/presentation".

    Thanks








  9. Nitin Nitin
    Nitin Nitin avatar
    41 posts
    Member since:
    Apr 2010

    Posted 08 Aug 2013 Link to this post

    Hi Rosen,

    It worked.

    I commented out the code for which the errors were thrown and it worked.

    Please just give me a solution for hiding those space on the left side so that the text can be aligned to left.

    Thanks,
    Nitin 

Back to Top
DevCraft banner