How to apply style using targetType from Resource Dictionary on RadMenuItem

5 posts, 0 answers
  1. Theo Foley
    Theo Foley avatar
    3 posts
    Member since:
    Sep 2009

    Posted 23 Sep 2009 Link to this post

    Hi,
    I'm trying to apply a style to all the RadMenuItem's, from the resource dictionary, using the syntax <Style TargetType="telerikNavigation:RadMenuItem">.

    I assumed that if x:key is not specified in my MainPage.xaml, the Style with TargetType="telerikNavigation:RadMenuItem" would get applied. However this is not the case.

    Do you know what I'm doing wrong? Any suggestions?

    Code in MainPage.xaml:

    <telerikNavigation:RadMenu FontFamily="Arial" FontSize="10" Grid.Row="1" Padding="0,0,0,0" MinWidth="250" HorizontalAlignment="Stretch" Orientation="Horizontal" >
                <telerikNavigation:RadMenuItem Header="Menu Placeholder 1"/>
                <telerikNavigation:RadMenuItem Header="Menu Placeholder 2" ></telerikNavigation:RadMenuItem>
                <telerikNavigation:RadMenuItem Header="Menu Placeholder 3"></telerikNavigation:RadMenuItem>
                <telerikNavigation:RadMenuItem Header="Menu Placeholder 4" ></telerikNavigation:RadMenuItem>
                <telerikNavigation:RadMenuItem Header="Menu Placeholder 5" ></telerikNavigation:RadMenuItem>
                <telerikNavigation:RadMenuItem Header="Menu Placeholder 6">
                    <telerikNavigation:RadMenuItem.Icon>
                        <Path x:Name="arrow" Stroke="Black" StrokeThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M8,1.5 L4.5,5 L1,1.5 z" Fill="#FF000000" Opacity="1"/>
                    </telerikNavigation:RadMenuItem.Icon>
                    <telerikNavigation:RadMenuItem Header="Sub Menu Item 7"></telerikNavigation:RadMenuItem>
                </telerikNavigation:RadMenuItem>

            </telerikNavigation:RadMenu>

    Code in ResourceDictionary:

    <SolidColorBrush x:Key="RadMenuTabBackground" Color="#FF202020"/>
     <SolidColorBrush x:Key="RadMenuPopUpOuterBorder" Color="#FF292929"/>
     <SolidColorBrush x:Key="RadMenuPopUp" Color="#FF202020"/>
     <SolidColorBrush x:Key="BorderInnerBrush" Color="#FF292929"/>
     <SolidColorBrush x:Key="SeparatorLine1" Color="#FF414141"/>
     <SolidColorBrush x:Key="RadMenu_PopupBackgroundLeftCol" Color="#FF202020"/>
     <SolidColorBrush x:Key="SeparatorLine2" Color="#7FFFFFFF"/>
     <SolidColorBrush x:Key="DisabledBrush" Color="#FF797979"/>
     <SolidColorBrush x:Key="RadMenuTabBorder_pressed" Color="#FFFA8C3B"/>
     <LinearGradientBrush x:Key="RadMenuTabBackground_pressed" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFFEB85D" Offset="1"/>
      <GradientStop Color="#FFFB933C" Offset="0"/>
     </LinearGradientBrush>
     <ControlTemplate x:Key="TopLevelHeaderTemplate" TargetType="telerikNavigation:RadMenuItem">
      <Grid x:Name="RootElement" Background="Transparent">
       <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStateGroup">
         <VisualState x:Name="Highlighted">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="Opacity">
            <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Focused">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="Opacity">
            <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="BorderBrush">
            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadMenuTabBorder_pressed}"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="Background">
            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadMenuTabBackground_pressed}"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Disabled">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Normal"/>
        </VisualStateGroup>
        <VisualStateGroup x:Name="CheckStateGroup">
         <VisualState x:Name="Checked">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Unchecked"/>
         <VisualState x:Name="HideIcon">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
        </VisualStateGroup>
       </VisualStateManager.VisualStateGroups>
       <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
       <Border x:Name="Bg" Margin="2" Opacity="0" Background="{StaticResource RadMenuTabBackground}" BorderBrush="#FFFFBC6B" BorderThickness="1" Padding="2 0"/>
       <telerik:RadDockPanel MinHeight="26">
        <ContentPresenter x:Name="Icon" Margin="4,0,0,0" VerticalAlignment="Center" Content="{TemplateBinding Icon}"/>
        <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" Margin="4,0,0,0" VerticalAlignment="Center" Visibility="Collapsed" Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z"/>
        <ContentPresenter x:Name="Content" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="8,2,8,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>
       </telerik:RadDockPanel>
       <Popup x:Name="PART_Popup">
        <Border x:Name="DropDownBorder" BorderBrush="{StaticResource RadMenuPopUpOuterBorder}" BorderThickness="1" CornerRadius="2">
         <Border x:Name="backgroundBorder" Background="{StaticResource RadMenuPopUp}" BorderBrush="{StaticResource BorderInnerBrush}" BorderThickness="1" CornerRadius="1">
          <Grid>
           <Border HorizontalAlignment="Left" Width="25" BorderBrush="{StaticResource SeparatorLine1}" BorderThickness="0 0 1 0">
            <Border Width="24" Background="{StaticResource RadMenu_PopupBackgroundLeftCol}" BorderBrush="{StaticResource SeparatorLine2}" BorderThickness="0 0 1 0"/>
           </Border>
           <ItemsPresenter/>
          </Grid>
         </Border>
        </Border>
       </Popup>
       <Rectangle x:Name="DisabledBox" Fill="{StaticResource DisabledBrush}" IsHitTestVisible="False" Visibility="Collapsed"/>
      </Grid>
     </ControlTemplate>
     <ControlTemplate x:Key="TopLevelItemTemplate" TargetType="telerikNavigation:RadMenuItem">
      <Grid x:Name="RootElement" Background="Transparent">
       <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStateGroup">
         <VisualState x:Name="Highlighted">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="Opacity">
            <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Focused">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="Opacity">
            <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="BorderBrush">
            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadMenuTabBorder_pressed}"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="Background">
            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource RadMenuTabBackground_pressed}"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Disabled">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Normal"/>
        </VisualStateGroup>
        <VisualStateGroup x:Name="CheckStateGroup">
         <VisualState x:Name="Checked">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Unchecked"/>
         <VisualState x:Name="HideIcon">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
        </VisualStateGroup>
       </VisualStateManager.VisualStateGroups>
       <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
       <Border x:Name="Bg" Margin="2" Opacity="0" Background="{StaticResource RadMenuTabBackground}" BorderBrush="#FFFFBC6B" BorderThickness="1" Padding="2 0"/>
       <telerik:RadDockPanel MinHeight="26">
        <ContentPresenter x:Name="Icon" Margin="4,0,0,0" VerticalAlignment="Center" Content="{TemplateBinding Icon}"/>
        <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" Margin="4,0,0,0" VerticalAlignment="Center" Visibility="Collapsed" Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z"/>
        <ContentPresenter x:Name="Content" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="8,2,16,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>
       </telerik:RadDockPanel>
       <Rectangle x:Name="DisabledBox" Fill="{StaticResource DisabledBrush}" IsHitTestVisible="False" Visibility="Collapsed"/>
      </Grid>
     </ControlTemplate>
     <LinearGradientBrush x:Key="NavigationMouseoverFill" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFFDFDF1" Offset="0"/>
      <GradientStop Color="#FFFDEDBD" Offset="1"/>
      <GradientStop Color="#FFFDF2CC" Offset="0.5"/>
      <GradientStop Color="#FFFDE6A5" Offset="0.51"/>
     </LinearGradientBrush>
     <LinearGradientBrush x:Key="NavigationMouseoverStroke" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFE8E0C2" Offset="0"/>
      <GradientStop Color="#FFE6E2D0" Offset="1"/>
     </LinearGradientBrush>
     <ControlTemplate x:Key="SubMenuHeaderTemplate" TargetType="telerikNavigation:RadMenuItem">
      <Grid x:Name="RootElement" Background="Transparent">
       <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStateGroup">
         <VisualState x:Name="Focused">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Fill">
            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NavigationMouseoverFill}"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Stroke">
            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource NavigationMouseoverStroke}"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Disabled">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Normal">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Fill">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
        </VisualStateGroup>
        <VisualStateGroup x:Name="CheckStateGroup">
         <VisualState x:Name="Checked">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Unchecked"/>
         <VisualState x:Name="HideIcon">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
        </VisualStateGroup>
       </VisualStateManager.VisualStateGroups>
       <Rectangle x:Name="InnerBorder" Fill="Transparent" Stroke="Transparent" RadiusX="2" RadiusY="2" Margin="2 1"/>
       <Grid MinHeight="24">
        <Grid.ColumnDefinitions>
         <ColumnDefinition MinWidth="24" Width="Auto"/>
         <ColumnDefinition Width="4"/>
         <ColumnDefinition Width="*"/>
         <ColumnDefinition Width="37"/>
         <ColumnDefinition Width="Auto"/>
         <ColumnDefinition Width="17"/>
        </Grid.ColumnDefinitions>
        <ContentPresenter x:Name="Icon" HorizontalAlignment="Center" Margin="1,0,0,0" VerticalAlignment="Center" Content="{TemplateBinding Icon}"/>
        <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" Height="11" Margin="1,0,0,0" Width="9" Visibility="Collapsed" Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z"/>
        <ContentPresenter x:Name="Content" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Column="2" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>
        <Path Fill="{TemplateBinding Foreground}" Margin="1,0,0,0" VerticalAlignment="Center" Width="9" Grid.Column="5" Data="M 0,0 L 4,3.5 L 0,7 Z"/>
       </Grid>
       <Popup x:Name="PART_Popup" HorizontalOffset="-3" VerticalOffset="-1">
        <Border BorderBrush="{StaticResource RadMenuPopUpOuterBorder}" BorderThickness="1,1,1,1" CornerRadius="2,2,2,2">
         <Border Background="{StaticResource RadMenuPopUp}" BorderBrush="{StaticResource BorderInnerBrush}" BorderThickness="1">
          <Grid>
           <Border HorizontalAlignment="Left" Width="25" BorderBrush="{StaticResource SeparatorLine1}" BorderThickness="0 0 1 0">
            <Border Width="24" Background="{StaticResource RadMenu_PopupBackgroundLeftCol}" BorderBrush="{StaticResource SeparatorLine2}" BorderThickness="0 0 1 0"/>
           </Border>
           <ItemsPresenter/>
          </Grid>
         </Border>
        </Border>
       </Popup>
       <Rectangle x:Name="DisabledBox" Fill="{StaticResource DisabledBrush}" IsHitTestVisible="False" Visibility="Collapsed"/>
      </Grid>
     </ControlTemplate>
     <ControlTemplate x:Key="SubMenuItemTemplate" TargetType="telerikNavigation:RadMenuItem">
      <Grid x:Name="RootElement" Background="Transparent">
       <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStateGroup">
         <VisualState x:Name="Highlighted">
          <Storyboard>
           <DoubleAnimation Duration="0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Opacity" To="1"/>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Disabled">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledBox" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Normal"/>
        </VisualStateGroup>
        <VisualStateGroup x:Name="CheckStateGroup">
         <VisualState x:Name="Checked">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="GlyphPanel" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
         <VisualState x:Name="Unchecked"/>
         <VisualState x:Name="HideIcon">
          <Storyboard>
           <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Icon" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
           </ObjectAnimationUsingKeyFrames>
          </Storyboard>
         </VisualState>
        </VisualStateGroup>
       </VisualStateManager.VisualStateGroups>
       <Rectangle x:Name="InnerBorder" Fill="{StaticResource NavigationMouseoverFill}" Stroke="{StaticResource NavigationMouseoverStroke}" RadiusX="2" RadiusY="2" Margin="2 1" Opacity="0"/>
       <Grid MinHeight="24">
        <Grid.ColumnDefinitions>
         <ColumnDefinition MinWidth="24" Width="Auto"/>
         <ColumnDefinition Width="4"/>
         <ColumnDefinition Width="*"/>
         <ColumnDefinition Width="37"/>
         <ColumnDefinition Width="Auto"/>
         <ColumnDefinition Width="17"/>
        </Grid.ColumnDefinitions>
        <ContentPresenter x:Name="Icon" Margin="1,0,0,0" VerticalAlignment="Center" Content="{TemplateBinding Icon}"/>
        <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" Height="11" Margin="1,0,0,0" Width="9" Visibility="Collapsed" Data="M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z"/>
        <ContentPresenter x:Name="Content" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Column="2" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>
       </Grid>
       <Rectangle x:Name="DisabledBox" Fill="{StaticResource DisabledBrush}" IsHitTestVisible="False" Visibility="Collapsed"/>
      </Grid>
     </ControlTemplate>
     <ControlTemplate x:Key="SeparatorTemplate" TargetType="telerikNavigation:RadMenuItem">
      <Grid Margin="0,6,0,4">
       <Rectangle Fill="{StaticResource SeparatorLine1}" Height="1" Margin="24,0,1,1"/>
       <Rectangle Fill="{StaticResource SeparatorLine2}" Height="1" Margin="25,1,1,0"/>
      </Grid>
     </ControlTemplate>
     <SolidColorBrush x:Key="Foreground_brush" Color="#FFFFFFFF"/>
     <Style TargetType="telerikNavigation: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}"/>
      <Setter Property="Template" Value="{StaticResource SubMenuItemTemplate}"/>
      <Setter Property="Padding" Value="2 0 0 0"/>
      <Setter Property="Foreground" Value="{StaticResource Foreground_brush}"/>
      <Setter Property="HorizontalContentAlignment" Value="Left"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="BorderThickness" Value="1"/>
     </Style>
  2. Theo Foley
    Theo Foley avatar
    3 posts
    Member since:
    Sep 2009

    Posted 02 Oct 2009 Link to this post

    So it looks like if I want to set the theme on the menu with my own style then I need to do something like this in the code behind.

    Telerik.Windows.Controls.Theme myTheme = new Telerik.Windows.Controls.Theme(new Uri "/Teltrik;component/Themes/TelerikMenuResourceDictionary.xaml", UriKind.RelativeOrAbsolute));

    StyleManager.SetTheme(menu, myTheme);

  3. DevCraft banner
  4. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 06 Oct 2009 Link to this post

    Hi Theo Foley,

    Implicit styles (without x:Key) are working only in WPF. This is Silverlight limitation that I hope will be removed in next silverlight version. The only way is to set x:Key on the Style and the reference it with {StaticResource theStyleKey}.

    Let us know if you need more information.

    Greetings,
    Hristo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Celeste
    Celeste avatar
    34 posts
    Member since:
    May 2009

    Posted 07 Oct 2009 Link to this post

    I' ve defined styles for so many controls, using ImplicitStyleManager in code behind. Including RadMenu, every control applied style I defined (without x:key) , but with RadMenuItem, it does not work. Why that could be?

  6. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 08 Oct 2009 Link to this post

    Hello Celeste,

    This was due to bug in RadMenuItem which is fixed.
    This fix will be included in the latest internal build.

    Best wishes,
    Hristo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner