I have been learning a lot about general workflows for styles and templates. I am using Resource Dictionaries to store my styles and my applications brushes and colors. I am currently working on styles and control templates for certain elements of my UI and I am struggling with making a control template for the MenuItem.
Currently I have made a short style for a Menu and I am looking to put MenuItem's within it (just like the standard Menu and MenuItems) but I can't seem to get any MenuItem's to show when using my style.
Here is my code snippet of my XAML for my Menu:
<!--Top Level Menu--><Style x:Key="S2ENGINE.TopLevelMenu" TargetType="{x:Type Menu}"><Setter Property="Height" Value="32"/><!--Setting Menu Template--><Setter Property="Template"><Setter.Value><!--Menu Template--><ControlTemplate TargetType="{x:Type Menu}"><Menu Background="{StaticResource S2ENGINEGradientBrush}" BorderBrush="{StaticResource S2ENGINEBorderBrushTransparent}" BorderThickness="0"/></ControlTemplate></Setter.Value></Setter></Style>
Here is a code snippet of my XAML for my MenuItem:
<!--Top Level MenuItems--><Style x:Key="S2ENGINE.TopLevelMenuItem" TargetType="{x:Type MenuItem}"><!--Setting MenuItems Template--><Setter Property="Template"><Setter.Value><!--Menu Template--><ControlTemplate TargetType="{x:Type MenuItem}"><MenuItem Foreground="{StaticResource S2ENGINETextBrush}" FontFamily="Segeo UI Light" FontSize="14" Header="{TemplateBinding Header}" Icon="{TemplateBinding Icon}" IsCheckable="{TemplateBinding IsCheckable}" ToolTip="{TemplateBinding ToolTip}" BorderThickness="0"><!--Content Placement--><ContentPresenter x:Name="MenuItemContentPresenter" VerticalAlignment="Center" HorizontalAlignment="Center"/></MenuItem></ControlTemplate></Setter.Value></Setter></Style>
I have a separate Resource Dictionary called "Brushes.xaml" which is just storing SolidColorBrush and LinearGradientBrush to use in my styles (just in case you were wondering what the StaticResource's were).
Here is the usage in my MainWindow.xaml:
<Grid><StackPanel><Menu Style="{StaticResource S2ENGINE.TopLevelMenu}"><MenuItem Header="File" Style="{StaticResource S2ENGINE.TopLevelMenuItem}"/><MenuItem Header="Edit" Style="{StaticResource S2ENGINE.TopLevelMenuItem}"/></Menu></StackPanel></Grid>
And here is a screenshot showing the result in Designer View:
I have two Headers there and nothing is showing up at all. Not to sure where I am going wrong. Any help is appreciated!
Thanks,
Dave.