i have created the custom control and in that style for menu item not working i have used the BasedOn key for apply the style
Generic XAML Code snippet
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication3">
<Style x:Key="MenuItemStyle" TargetType="{x:Type MenuItem}">
<Setter Property="Height" Value="60"/>
<Setter Property="Background" Value="Red"/>
</Style>
<Style BasedOn="{StaticResource ResourceKey=MenuItemStyle}" TargetType="{x:Type MenuItem}"/>
<Style TargetType="{x:Type local:CustomControl1}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl1}">
<Grid x:Name="MainGrid">
<Menu>
<MenuItem Header="File" />
</Menu>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
The style is not applying for MenuItem, while adding style like below code is working , how to achieve this using Based on , Since in my scnorio i have use multiple menuitems
you have two options here
remove the key from style
eg
this will apply this style to all the menu items in the scope.
note: if you find it not working for you then try defining the style in Menu's resources.
or apply the style directly to menu item leaving the key in style
eg
this will apply the style to the desired menu item only
this style does not serve any purpose