Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

WPF Business Application Series Part 2 of n - Form Notification Control that Binds to the IDataErrorInfo.Error Property

, 2 Apr 2008 CPOL
WPF VB.NET Business Application Form Notification control that binds to business entity objects that implement the IDataErrorInfo interface. The article also covers entity validation with the WPF 3.5 IDataErrorInfo interface.
wpflobparttwo.zip
WPFLOBPartTwo
Core
Core.csi
Core.vbproj.user
My Project
Settings.settings
Themes
WPF
Converters
Custom Controls
CustomToolBarButton
FormNotification
Time Display
Helpers
DemonstrationForms
Business Object
DemonstrationForms.csi
Forms
My Project
Settings.settings
WPFBusiessApplicationSample.suo
WPFBusinessApplicationSample
My Project
MyExtensions
Settings.settings
Resources
Images
Delete.png
DeleteDisabled.png
New.png
NewDisabled.png
rss.png
rss3d.png
Save.png
SaveDisabled.png
Skins
Metallic
OfficeBlack
OfficeBlue
WPFBusiessApplicationSample.csi
WPFBusiessApplicationSample.vbproj.user
WPFToolBarButtonSample.csi
wpflobparttwoupdated2-23-2008.zip
Core.csi
Core.vbproj.user
Settings.settings
DemonstrationForms.csi
Settings.settings
Settings.settings
Delete.png
DeleteDisabled.png
New.png
NewDisabled.png
rss.png
rss3d.png
Save.png
SaveDisabled.png
WPFBusiessApplicationSample.csi
WPFBusiessApplicationSample.vbproj.user
WPFToolBarButtonSample.csi
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Core_WPF="clr-namespace:Core.WPF;assembly=Core" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">

    <!-- Application Brushes -->
    <SolidColorBrush x:Key="Brush_TextForeground" Color="Black" />

    <SolidColorBrush x:Key="Brush_MenuTopLevelTextForeground" Color="Black" />

        <SolidColorBrush x:Key="Brush_FormHeadingText" Color="#FF545454" />

    <SolidColorBrush x:Key="Brush_FormSubHeadingText" Color="#FF545454" />

	<SolidColorBrush x:Key="Brush_BrightBackground" Color="#FFEBEBEB"/>

    <SolidColorBrush x:Key="Brush_DarkBackground" Color="#FF545454"/>

    <!-- This is used for the text above the mouse over popup tooltips  -->
    <LinearGradientBrush x:Key="Brush_WindowPreviewTitleBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#F3F3F3" Offset="0" />
        <GradientStop Color="#EBEBEB" Offset="0.5" />
        <GradientStop Color="#DDDDDD" Offset="0.5" />
        <GradientStop Color="#CDCDCD" Offset="1" />
    </LinearGradientBrush>

    <!-- MDI Tab Control Brushes -->
    <SolidColorBrush x:Key="Brush_LightTabItemBackground" Color="#FFE0E0E0"/>
    
    <LinearGradientBrush x:Key="Brush_TabItemBackgroundBorder" EndPoint="0.5,-0.175" StartPoint="0.5,1.175">
        <GradientStop Color="#FF626262" Offset="0.445" />
        <GradientStop Color="#FFC8C8C8" Offset="0.855" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="Brush_WindowBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#FFC8C8C8" Offset="0" />
        <GradientStop Color="#FFE2E2E2" Offset="1" />
        <GradientStop Color="#FFFFFFFF" Offset="0.105"/>
        <GradientStop Color="#FFC8C8C8" Offset="0.07"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="Brush_TabItemSelected" Color="#FFE2E2E2"/>

    <SolidColorBrush x:Key="Brush_TabItemNotSelected" Color="#FFFFFFFF"/>

    <SolidColorBrush x:Key="Brush_TabControlNormalBorderBrush" Color="#8C8E94" />

    <LinearGradientBrush x:Key="Brush_TabControlButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#F3F3F3" Offset="0" />
        <GradientStop Color="#EBEBEB" Offset="0.5" />
        <GradientStop Color="#DDDDDD" Offset="0.5" />
        <GradientStop Color="#CDCDCD" Offset="1" />
    </LinearGradientBrush>

    <SolidColorBrush x:Key="Brush_TabItemDisabledBackground" Color="#F4F4F4" />

    <SolidColorBrush x:Key="Brush_TabItemDisabledBorderBrush" Color="#FFC9C7BA" />

    <!-- ToolBar Control Brushes -->

    <LinearGradientBrush x:Key="Brush_ToolBarOverflowRegion" EndPoint="0.5,-0.175" StartPoint="0.5,1.175">
        <GradientStop Color="#FFE7E7E7" Offset="0.445" />
        <GradientStop Color="#FFF9F9F9" Offset="0.83" />
        <GradientStop Color="#FFE7E7E7" Offset="1"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="Brush_ToolBarButtonBorder" Color="#FFFB8C3C" />

    <LinearGradientBrush x:Key="Brush_ToolBarBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#FFC8C8C8" Offset="0" />
        <GradientStop Color="#FFEFEFEF" Offset="0.105" />
        <GradientStop Color="#FFC8C8C8" Offset="0.52" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="Brush_ToolBarMouseOverBackground" EndPoint="0,1" StartPoint="0,0" SpreadMethod="Reflect">
        <GradientStop Color="#FFFFF5CB" Offset="0.2" />
        <GradientStop Color="#FFFFE290" Offset="0.6" />
        <GradientStop Color="#FFFFDB76" Offset="1" />
        <GradientStop Color="#FFFFF8D5" Offset="0" />
    </LinearGradientBrush>

    <SolidColorBrush x:Key="Brush_ToolBarMouseOverForeground" Color="Black" />
    
    <LinearGradientBrush x:Key="Brush_ToolBarButtonPressed" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#FFFB923C" Offset="0" />
        <GradientStop Color="#FFFC953C" Offset="0.0967741935483871" />
        <GradientStop Color="#FFFD9D3D" Offset="0.303" />
        <GradientStop Color="#FFFFAB3F" Offset="0.551" />
        <GradientStop Color="#FFFFB14D" Offset="0.788" />
        <GradientStop Color="#FFFFB85D" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="Brush_ToolBarHorizontalBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#FFFFFF" Offset="0" />
        <GradientStop Color="#FFFBFF" Offset="0.5" />
        <GradientStop Color="#F7F7F7" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="Brush_ToolBarToggleButtonHorizontalBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#ECECEC" Offset="0" />
        <GradientStop Color="#DDDDDD" Offset="0.5" />
        <GradientStop Color="#A0A0A0" Offset="1" />
    </LinearGradientBrush>

    <SolidColorBrush x:Key="Brush_ToolBarGripper" Color="#C6C3C6" />

    <SolidColorBrush x:Key="Brush_ToolBarSubMenuBackground" Color="#FDFDFD" />

    <SolidColorBrush x:Key="Brush_ToolBarMenuBorder" Color="#808080" />

    <LinearGradientBrush x:Key="Brush_ToolBarToggleButtonVerticalBackground" EndPoint="1,0" StartPoint="0,0">
        <GradientStop Color="#ECECEC" Offset="0" />
        <GradientStop Color="#DDDDDD" Offset="0.5" />
        <GradientStop Color="#A0A0A0" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="Brush_ToolBarVerticalBackground" EndPoint="1,0" StartPoint="0,0">
        <GradientStop Color="#FFFFFF" Offset="0" />
        <GradientStop Color="#FFFBFF" Offset="0.5" />
        <GradientStop Color="#F7F7F7" Offset="1" />
    </LinearGradientBrush>

    <!-- ===================================================================================================================================== -->
    <!-- Control styles -->
    
    <!-- TextBox Control Style -->

    <ControlTemplate x:Key="validationTemplate">
        <DockPanel>
            <TextBlock Margin="5,0,5,0" Foreground="Red" FontSize="16" VerticalAlignment="Center" Text="*" />
                             <AdornedElementPlaceholder />
                        </DockPanel>
    </ControlTemplate>

    <Style TargetType="{x:Type TextBox}">
        <Setter Property="Validation.ErrorTemplate" Value="{DynamicResource validationTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Border Width="Auto" Height="Auto" BorderThickness="2,2,1,1" Padding="2,2,2,2" CornerRadius="8,8,8,8" Background="{TemplateBinding Background}">
                        <Border.BorderBrush>
                            <LinearGradientBrush EndPoint="0.5,-0.358" StartPoint="0.5,0.32">
                                <GradientStop Color="#13000000" Offset="0" />
                                <GradientStop Color="#FF909090" Offset="1" />
                            </LinearGradientBrush>
                        </Border.BorderBrush>
                        <Microsoft_Windows_Themes:ListBoxChrome SnapsToDevicePixels="True" x:Name="Bd" Width="Auto" Height="Auto" Background="{TemplateBinding Background}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" RenderMouseOver="{TemplateBinding IsMouseOver}" BorderThickness="0,0,0,0">
                            <ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost" />
                        </Microsoft_Windows_Themes:ListBoxChrome>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip" Value="{Binding Path=(Validation.Errors)[0].ErrorContent, RelativeSource={x:Static RelativeSource.Self}}" />
            </Trigger>
        </Style.Triggers>
   </Style>

    <!-- ===================================================================================================================================== -->
    <!-- ToolBar ControlTemplate -->
    <!-- ToolBar Styles -->

    <!-- ===================================================================================================================================== -->

    <!-- ===================================================================================================================================== -->

    <!-- Application Border Style - Used on the Application Main Window, wraps the tab control -->
    <Style x:Key="Application_Border" TargetType="{x:Type Border}">
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush_TabItemBackgroundBorder}" />
        <Setter Property="BorderThickness" Value="4,0,4,4" />
    </Style>
    
    <!-- UserControl Form Styles - Used on all application UserControl forms -->
    <Style x:Key="UserControl_Form_Outer_Border" TargetType="{x:Type Border}">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="DockPanel.Dock" Value="Top" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="BorderThickness" Value="3" />
    </Style>
    
    <Style x:Key="UserControl_Form_Inner_Border" TargetType="{x:Type Border}">
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Cycle" />
        <Setter Property="Padding" Value="10" />
        <Setter Property="Margin" Value="10,5,10,10" />
        <Setter Property="CornerRadius" Value="10" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush_DarkBackground}" />
        <Setter Property="Background" Value="{DynamicResource Brush_LightTabItemBackground}" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="BorderThickness" Value="1" />
    </Style>
    
    <!-- ToolBar Tray Styles -->
    <Style TargetType="{x:Type ToolBarTray}">
        <Setter Property="Background" Value="{DynamicResource Brush_ToolBarBackground}" />
        <Setter Property="DockPanel.Dock" Value="Top" />
    </Style>

    
    <!-- ToolBar Button Styles -->
    <Style TargetType="{x:Type Core_WPF:CustomToolBarButton}">
        <Setter Property="ButtonPressedBackground" Value="{DynamicResource Brush_ToolBarButtonPressed}" />
        <Setter Property="ButtonPressedBorder" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
        <Setter Property="MouseOverBackground" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
        <Setter Property="MouseOverBorder" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
        <Setter Property="MouseOverForeground" Value="{DynamicResource Brush_ToolBarMouseOverForeground}" />
    </Style>

    <!-- ===================================================================================================================================== -->
    <!-- ToolBar ControlTemplate -->
    <!--  see http://msdn2.microsoft.com/en-us/library/system.windows.input.keyboardnavigationmode.aspx -->
    
    <Style TargetType="{x:Type ToolBar}">
        <Setter Property="DockPanel.Dock" Value="Top" />
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Continue" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="BorderBrush" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource Brush_TextForeground}" />
        <Setter Property="HorizontalAlignment" Value="Left" />

        <Setter Property="Template">
            <Setter.Value>
               <ControlTemplate TargetType="{x:Type ToolBar}">
        <Grid SnapsToDevicePixels="True" Margin="3,1,1,1" x:Name="Grid">
            <Grid HorizontalAlignment="Right" x:Name="OverflowGrid">
                <ToggleButton IsEnabled="{TemplateBinding HasOverflowItems}" FocusVisualStyle="{x:Null}" x:Name="OverflowButton" ClickMode="Press" IsChecked="{Binding Path=IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Background="{DynamicResource Brush_ToolBarOverflowRegion}">
                    <ToggleButton.Style>
                        <Style TargetType="{x:Type ToggleButton}">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                        <GradientStop Color="#FFECECEC" Offset="0" />
                                        <GradientStop Color="#FFDDDDDD" Offset="0.5" />
                                        <GradientStop Color="#FFA0A0A0" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="MinHeight" Value="0" />
                            <Setter Property="MinWidth" Value="0" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                                        <Border SnapsToDevicePixels="True" x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="0,3,3,0">
                                            <Canvas SnapsToDevicePixels="True" HorizontalAlignment="Right" Margin="7,2,2,2" VerticalAlignment="Bottom" Width="6" Height="7">
                                                <Path Stroke="#FFFFFFFF" Data="M1,1.5L6,1.5" />
                                                <Path Stroke="{TemplateBinding Foreground}" Data="M0,0.5L5,0.5" />
                                                <Path Fill="#FFFFFFFF" Data="M0.5,4L6.5,4 3.5,7z" />
                                                <Path Fill="{TemplateBinding Foreground}" Data="M-0.5,3L5.5,3 2.5,6z" />
                                            </Canvas>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                                            </Trigger>
                                            <Trigger Property="IsKeyboardFocused" Value="True">
                                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                                            </Trigger>
                                            <Trigger Property="IsEnabled" Value="False">
                                                <Setter Property="Foreground" Value="#FFC6C3C6" />
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ToggleButton.Style>
                </ToggleButton>
                <Popup Focusable="False" AllowsTransparency="True" IsOpen="{Binding Path=IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" StaysOpen="False" x:Name="OverflowPopup">
                    <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="#00FFFFFF">
                        <Border Background="#FFFDFDFD" BorderBrush="#FF808080" BorderThickness="1,1,1,1">
                            <ToolBarOverflowPanel Focusable="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" FocusVisualStyle="{x:Null}" Margin="2,2,2,2" x:Name="PART_ToolBarOverflowPanel" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle" WrapWidth="200" />
                        </Border>
                    </Microsoft_Windows_Themes:SystemDropShadowChrome>
                </Popup>
            </Grid>
            <Border Margin="0,0,11,0" x:Name="MainPanelBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3,3,3,3" Padding="{TemplateBinding Padding}">
                <DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
                    <Thumb  Padding="6,5,1,6" Margin="-3,-1,0,0" x:Name="ToolBarThumb" Width="10">
                        <Thumb.Style>
                            <Style TargetType="{x:Type Thumb}">

                                            <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Thumb}">
                                            <Border SnapsToDevicePixels="True" Background="#00FFFFFF" Padding="{TemplateBinding Padding}">
                                                <Rectangle>
                                                    <Rectangle.Fill>
                                                        <DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" ViewboxUnits="Absolute" Viewport="0,0,4,4" ViewportUnits="Absolute">
                                                            <DrawingBrush.Drawing>
                                                                <DrawingGroup>
                                                                    <GeometryDrawing Brush="#FFFFFFFF" Geometry="M1,1L1,3 3,3 3,1z" />
                                                                    <GeometryDrawing Brush="#FFC6C3C6" Geometry="M0,0L0,2 2,2 2,0z" />
                                                                </DrawingGroup>
                                                            </DrawingBrush.Drawing>
                                                        </DrawingBrush>
                                                    </Rectangle.Fill>
                                                </Rectangle>
                                            </Border>
                                            <!--<ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Cursor" Value="SizeAll" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>-->
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Thumb.Style>
                    </Thumb>
                    <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Center" Margin="4,0,4,0" x:Name="ToolBarHeader" VerticalAlignment="Center" Content="{TemplateBinding Header}" ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" />
                    <ToolBarPanel SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,1,2,2" x:Name="PART_ToolBarPanel" IsItemsHost="True" />
                </DockPanel>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsOverflowOpen" Value="True">
                <Setter Property="IsEnabled" TargetName="ToolBarThumb" Value="False" />
            </Trigger>
            <Trigger Property="Header" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="ToolBarHeader" Value="Collapsed" />
            </Trigger>
            <Trigger Property="ToolBarTray.IsLocked" Value="True">
                <Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed" />
            </Trigger>
            <Trigger Property="HasDropShadow" SourceName="OverflowPopup" Value="True">
                <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5" />
                <Setter Property="SnapsToDevicePixels" TargetName="Shdw" Value="True" />
                <Setter Property="Color" TargetName="Shdw" Value="#71000000" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Margin" TargetName="Grid" Value="1,3,1,1" />
                <Setter Property="Style" TargetName="OverflowButton">
                    <Setter.Value>
                        <Style TargetType="{x:Type ToggleButton}">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
                                        <GradientStop Color="#FFECECEC" Offset="0" />
                                        <GradientStop Color="#FFDDDDDD" Offset="0.5" />
                                        <GradientStop Color="#FFA0A0A0" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="MinHeight" Value="0" />
                            <Setter Property="MinWidth" Value="0" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                                        <Border SnapsToDevicePixels="True" x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="0,0,3,3">
                                            <Canvas SnapsToDevicePixels="True" HorizontalAlignment="Right" Margin="2,7,2,2" VerticalAlignment="Bottom" Width="7" Height="6">
                                                <Path Stroke="#FFFFFFFF" Data="M1.5,1L1.5,6" />
                                                <Path Stroke="{TemplateBinding Foreground}" Data="M0.5,0L0.5,5" />
                                                <Path Fill="#FFFFFFFF" Data="M3.5,0.5L7,3.5 4,6.5z" />
                                                <Path Fill="{TemplateBinding Foreground}" Data="M3,-0.5L6,2.5 3,5.5z" />
                                            </Canvas>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter Property="Background" TargetName="Bd" Value="#FFC2E0FF" />
                                            </Trigger>
                                            <Trigger Property="IsKeyboardFocused" Value="True">
                                                <Setter Property="Background" TargetName="Bd" Value="#FFC2E0FF" />
                                            </Trigger>
                                            <Trigger Property="IsEnabled" Value="False">
                                                <Setter Property="Foreground" Value="#FFC6C3C6" />
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="Height" TargetName="ToolBarThumb" Value="10" />
                <Setter Property="Width" TargetName="ToolBarThumb" Value="NaN" />
                <Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0" />
                <Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1" />
                <Setter Property="Margin" TargetName="ToolBarHeader" Value="0,0,0,4" />
                <Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="1,0,2,2" />
                <Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top" />
                <Setter Property="DockPanel.Dock" TargetName="ToolBarHeader" Value="Top" />
                <Setter Property="HorizontalAlignment" TargetName="OverflowGrid" Value="Stretch" />
                <Setter Property="VerticalAlignment" TargetName="OverflowGrid" Value="Bottom" />
                <Setter Property="Placement" TargetName="OverflowPopup" Value="Right" />
                <Setter Property="Margin" TargetName="MainPanelBorder" Value="0,0,0,11" />
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
                            <GradientStop Color="#FFFFFFFF" Offset="0" />
                            <GradientStop Color="#FFFFFBFF" Offset="0.5" />
                            <GradientStop Color="#FFF7F7F7" Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Tab TabItem ControlTemplates -->

    <Style x:Key="TabItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle SnapsToDevicePixels="true" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="3,3,3,1" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TabItemStyle_Application" TargetType="{x:Type TabItem}">
        <Setter Property="Background" Value="{DynamicResource Brush_ToolBarBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource Brush_FormHeadingText}" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource TabItemFocusVisual}" />
        <Setter Property="Padding" Value="6,1,6,1" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush_TabControlNormalBorderBrush}" />
        <Setter Property="Background" Value="{DynamicResource Brush_TabControlButtonNormalBackground}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid SnapsToDevicePixels="true">
                        <Border x:Name="Bd" Padding="{TemplateBinding Padding}" Background="{DynamicResource Brush_TabItemNotSelected}" BorderBrush="{DynamicResource Brush_DarkBackground}" >
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" x:Name="Content" VerticalAlignment="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" ContentSource="Header" RecognizesAccessKey="True" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Panel.ZIndex" Value="1" />
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource Brush_TabItemSelected}" />
                            <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource Brush_DarkBackground}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="MinWidth" Value="0" SourceName="Bd" />
                                <Condition Property="IsMouseOver" Value="true" SourceName="Bd" />
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource Brush_TabItemSelected}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="false" />
                                <Condition Property="IsMouseOver" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                            <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                        </MultiTrigger>
                        <Trigger Property="TabStripPlacement" Value="Top">
                            <Setter Property="CornerRadius" TargetName="Bd" Value="6,6,0,0" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="BorderThickness" TargetName="Bd" Value="1,0,1,1" />
                            <Setter Property="CornerRadius" TargetName="Bd" Value="0,0,6,6" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="BorderThickness" TargetName="Bd" Value="1,1,0,1" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="BorderThickness" TargetName="Bd" Value="0,1,1,1" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true" />
                                <Condition Property="TabStripPlacement" Value="Top" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="0,-2,-2,-1" />
                            <Setter Property="Margin" TargetName="Content" Value="0,0,0,1" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true" />
                                <Condition Property="TabStripPlacement" Value="Bottom" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="0,-1,-2,-2" />
                            <Setter Property="Margin" TargetName="Content" Value="0,1,0,0" />
                            <Setter Property="Margin" TargetName="Bd" Value="-0.309,0,0.309,0" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true" />
                                <Condition Property="TabStripPlacement" Value="Left" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-2,-2,-1,-2" />
                            <Setter Property="Margin" TargetName="Content" Value="0,0,1,0" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true" />
                                <Condition Property="TabStripPlacement" Value="Right" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-1,-2,-2,-2" />
                            <Setter Property="Margin" TargetName="Content" Value="1,0,0,0" />
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource Brush_TabItemDisabledBackground}" />
                            <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource Brush_TabItemDisabledBorderBrush}" />
                            <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TabControlStyle_Application" TargetType="{x:Type TabControl}">
        <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="Padding" Value="4" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush_TabControlNormalBorderBrush}" />
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="0,0,0,0" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="Margin" Value="0,0,0,0" />
        <Setter Property="TabStripPlacement" Value="Bottom" />
        <Setter Property="IsSynchronizedWithCurrentItem" Value="True" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0" />
                            <ColumnDefinition Width="0" x:Name="ColumnDefinition1" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto" />
                            <RowDefinition x:Name="RowDefinition1" Height="*" />
                        </Grid.RowDefinitions>
                        <Border x:Name="ContentPanel" Background="{TemplateBinding Background}" BorderBrush="{DynamicResource Brush_DarkBackground}" BorderThickness="{TemplateBinding BorderThickness}" Grid.Column="0" Grid.Row="1" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" />
                        </Border>
                        <Border x:Name="HeaderPanelBorder" Margin="0,0,0,0" BorderBrush="{DynamicResource Brush_DarkBackground}" Grid.Column="0" Grid.Row="0" BorderThickness="1,0,1,0" Padding="4,0,4,0">
                            <TabPanel x:Name="HeaderPanel" IsItemsHost="true" Panel.ZIndex="1" KeyboardNavigation.TabIndex="1" Margin="0,4,0,0" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="HeaderPanelBorder" Value="1" />
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto" />
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="0,0,0,4" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="Grid.Row" TargetName="HeaderPanelBorder" Value="0" />
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Grid.Column" TargetName="HeaderPanelBorder" Value="0" />
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1" />
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto" />
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0" />
                            <Setter Property="Margin" TargetName="HeaderPanelBorder" Value="2,2,0,2" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="Grid.Row" TargetName="HeaderPanelBorder" Value="0" />
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Grid.Column" TargetName="HeaderPanelBorder" Value="1" />
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0" />
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="*" />
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto" />
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*" />
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0" />
                            <Setter Property="Margin" TargetName="HeaderPanelBorder" Value="0,2,2,2" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Menu, MenuItem ControlTemplates -->

    <Geometry x:Key="Checkmark">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</Geometry>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="true">
            <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="2" RadiusY="2" x:Name="Bg" />
            <Rectangle RadiusX="2" RadiusY="2" Margin="1" x:Name="InnerBorder" />
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="24" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
                    <ColumnDefinition Width="4" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="37" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
                    <ColumnDefinition Width="17" />
                </Grid.ColumnDefinitions>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="1" x:Name="Icon" VerticalAlignment="Center" ContentSource="Icon" />
                <Border Visibility="Hidden" Margin="1" x:Name="GlyphPanel" Width="22" Height="22" Background="#E6EFF4" BorderBrush="#CDD3E6" BorderThickness="1" CornerRadius="3">
                    <Path Fill="#0C12A1" FlowDirection="LeftToRight" x:Name="Glyph" Width="9" Height="11" Data="{StaticResource Checkmark}" />
                </Border>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Grid.Column="2" ContentSource="Header" RecognizesAccessKey="True" />
                <TextBlock Margin="{TemplateBinding Padding}" Text="{TemplateBinding InputGestureText}" Grid.Column="4" />
            </Grid>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible" />
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                <Setter Property="Stroke" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                <Setter Property="Stroke" TargetName="InnerBorder" Value="#40FFFFFF" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="#FF9A9A9A" />
                <Setter Property="Background" TargetName="GlyphPanel" Value="#EEE9E9" />
                <Setter Property="BorderBrush" TargetName="GlyphPanel" Value="#DBD6D6" />
                <Setter Property="Fill" TargetName="Glyph" Value="#848589" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />

    <Style x:Key="MenuScrollButton" BasedOn="{x:Null}" TargetType="{x:Type RepeatButton}">
        <Setter Property="ClickMode" Value="Hover" />
        <Setter Property="MinWidth" Value="0" />
        <Setter Property="MinHeight" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <DockPanel SnapsToDevicePixels="true" Background="Transparent">
                        <Rectangle Fill="Transparent" x:Name="R1" Width="1" DockPanel.Dock="Right" />
                        <Rectangle Fill="Transparent" x:Name="B1" Height="1" DockPanel.Dock="Bottom" />
                        <Rectangle Fill="Transparent" x:Name="L1" Width="1" DockPanel.Dock="Left" />
                        <Rectangle Fill="Transparent" x:Name="T1" Height="1" DockPanel.Dock="Top" />
                        <ContentPresenter HorizontalAlignment="Center" Margin="2,2,2,2" x:Name="ContentContainer" VerticalAlignment="Center" />
                    </DockPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Fill" TargetName="R1" Value="{StaticResource {x:Static SystemColors.ControlLightLightBrushKey}}" />
                            <Setter Property="Fill" TargetName="B1" Value="{StaticResource {x:Static SystemColors.ControlLightLightBrushKey}}" />
                            <Setter Property="Fill" TargetName="L1" Value="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
                            <Setter Property="Fill" TargetName="T1" Value="{StaticResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
                            <Setter Property="Margin" TargetName="ContentContainer" Value="3,3,1,1" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Geometry x:Key="UpArrow">M 0,4 L 3.5,0 L 7,4 Z</Geometry>

    <Geometry x:Key="DownArrow">M 0,0 L 3.5,4 L 7,0 Z</Geometry>

    <Style x:Key="{ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}" BasedOn="{x:Null}" TargetType="{x:Type ScrollViewer}">
        <Setter Property="HorizontalScrollBarVisibility" Value="Hidden" />
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.Column="0" Grid.Row="1">
                            <ScrollContentPresenter Margin="{TemplateBinding Padding}" />
                        </Border>
                        <RepeatButton Focusable="false" Style="{StaticResource MenuScrollButton}" Command="{x:Static ScrollBar.LineUpCommand}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Grid.Column="0" Grid.Row="0">
                            <RepeatButton.Visibility>
                                <MultiBinding FallbackValue="Visibility.Collapsed" Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="0">
                                    <Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}" />
                                    <Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}" />
                                    <Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}" />
                                    <Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}" />
                                </MultiBinding>
                            </RepeatButton.Visibility>
                            <Path Fill="{StaticResource {x:Static SystemColors.MenuTextBrushKey}}" Data="{StaticResource UpArrow}" />
                        </RepeatButton>
                        <RepeatButton Focusable="false" Style="{StaticResource MenuScrollButton}" Command="{x:Static ScrollBar.LineDownCommand}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Grid.Column="0" Grid.Row="2">
                            <RepeatButton.Visibility>
                                <MultiBinding FallbackValue="Visibility.Collapsed" Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="100">
                                    <Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}" />
                                    <Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}" />
                                    <Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}" />
                                    <Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}" />
                                </MultiBinding>
                            </RepeatButton.Visibility>
                            <Path Fill="{StaticResource {x:Static SystemColors.MenuTextBrushKey}}" Data="{StaticResource DownArrow}" />
                        </RepeatButton>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}" TargetType="{x:Type ContentControl}">
        <Border Background="#F5F5F5" BorderBrush="#FF959595" BorderThickness="1">
            <Grid>
                <Rectangle Fill="#F1F1F1" RadiusX="2" RadiusY="2" HorizontalAlignment="Left" Margin="2" Width="28" />
                <Rectangle Fill="#E2E3E3" HorizontalAlignment="Left" Margin="30,2,0,2" Width="1" />
                <Rectangle Fill="White" HorizontalAlignment="Left" Margin="31,2,0,2" Width="1" />
                <ContentPresenter Margin="1,0" Grid.ColumnSpan="2" />
            </Grid>
        </Border>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="true">
            <Rectangle RadiusX="2" RadiusY="2" x:Name="OuterBorder" />
            <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="1" RadiusY="1" Margin="1" x:Name="Bg" />
            <Rectangle Margin="2" x:Name="InnerBorder" />
            <DockPanel>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="4,0,6,0" x:Name="Icon" VerticalAlignment="Center" ContentSource="Icon" />
                <Path Visibility="Collapsed" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="7,0,0,0" x:Name="GlyphPanel" VerticalAlignment="Center" Data="{StaticResource Checkmark}" />
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" ContentSource="Header" RecognizesAccessKey="True" />
            </DockPanel>
            <Popup Focusable="false" AllowsTransparency="true" HorizontalOffset="1" IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{StaticResource {x:Static SystemParameters.MenuPopupAnimationKey}}" VerticalOffset="-1" x:Name="PART_Popup">
                <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
                    <ContentControl x:Name="SubMenuBorder" IsTabStop="false" Template="{StaticResource {ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                        <ScrollViewer Style="{StaticResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" CanContentScroll="true">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0" Grid.IsSharedSizeScope="true" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle" />
                        </ScrollViewer>
                    </ContentControl>
                </Microsoft_Windows_Themes:SystemDropShadowChrome>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None" />
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible" />
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
                <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5" />
                <Setter Property="Color" TargetName="Shdw" Value="#71000000" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Stroke" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                <Setter Property="Stroke" TargetName="OuterBorder" Value="#50FFFFFF" />
                <Setter Property="Stroke" TargetName="InnerBorder" Value="#50FFFFFF" />

            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="Stroke" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                <Setter Property="Stroke" TargetName="InnerBorder" Value="#50747272" />

            </Trigger>
            <Trigger Property="IsSubmenuOpen" Value="true">
                <Setter Property="Stroke" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonPressed}" />
                <Setter Property="Stroke" TargetName="InnerBorder" Value="#50747272" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="#FF9A9A9A" />
                <Setter Property="Fill" TargetName="GlyphPanel" Value="#848589" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="ComponentResourceKey2" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="true">
            <Rectangle RadiusX="2" RadiusY="2" x:Name="OuterBorder" />
            <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="1" RadiusY="1" Margin="1" x:Name="Bg" />
            <Rectangle Margin="2" x:Name="InnerBorder" />
            <DockPanel>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="4,0,6,0" x:Name="Icon" VerticalAlignment="Center" ContentSource="Icon" />
                <Path Visibility="Collapsed" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="7,0,0,0" x:Name="GlyphPanel" VerticalAlignment="Center" Data="{StaticResource Checkmark}" />
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" ContentSource="Header" RecognizesAccessKey="True" />
            </DockPanel>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible" />
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Stroke" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                <Setter Property="Stroke" TargetName="OuterBorder" Value="#50FFFFFF" />
                <Setter Property="Stroke" TargetName="InnerBorder" Value="#50FFFFFF" />
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="Stroke" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
                <Setter Property="Stroke" TargetName="InnerBorder" Value="#50747272" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="#FF9A9A9A" />
                <Setter Property="Fill" TargetName="GlyphPanel" Value="#848589" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Geometry x:Key="RightArrow">M 0,0 L 4,3.5 L 0,7 Z</Geometry>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="true">
            <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="2" RadiusY="2" x:Name="Bg" />
            <Rectangle Stroke="Transparent" StrokeThickness="1" RadiusX="2" RadiusY="2" Margin="1" x:Name="InnerBorder" />
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="24" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
                    <ColumnDefinition Width="4" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="37" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
                    <ColumnDefinition Width="17" />
                </Grid.ColumnDefinitions>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="1" x:Name="Icon" VerticalAlignment="Center" ContentSource="Icon" />
                <Border Visibility="Hidden" Margin="1" x:Name="GlyphPanel" Width="22" Height="22" Background="#E6EFF4" BorderBrush="#CDD3E6" BorderThickness="1" CornerRadius="3">
                    <Path Fill="#0C12A1" FlowDirection="LeftToRight" x:Name="Glyph" Width="9" Height="11" Data="{StaticResource Checkmark}" />
                </Border>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Grid.Column="2" ContentSource="Header" RecognizesAccessKey="True" />
                <TextBlock Visibility="Collapsed" Margin="{TemplateBinding Padding}" Text="{TemplateBinding InputGestureText}" Grid.Column="4" />
                <Path Fill="{TemplateBinding Foreground}" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="5" Data="{StaticResource RightArrow}" />
            </Grid>
            <Popup Focusable="false" AllowsTransparency="true" HorizontalOffset="-2" IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PopupAnimation="{StaticResource {x:Static SystemParameters.MenuPopupAnimationKey}}" VerticalOffset="-3" x:Name="PART_Popup">
                <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
                    <ContentControl x:Name="SubMenuBorder" IsTabStop="false" Template="{StaticResource {ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                        <ScrollViewer Style="{StaticResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" CanContentScroll="true">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0" Grid.IsSharedSizeScope="true" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle" />
                        </ScrollViewer>
                    </ContentControl>
                </Microsoft_Windows_Themes:SystemDropShadowChrome>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Stroke" TargetName="InnerBorder" Value="#D1DBF4FF" />
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible" />
                <Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
            </Trigger>
            <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
                <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5" />
                <Setter Property="Color" TargetName="Shdw" Value="#71000000" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Stroke" TargetName="Bg" Value="{DynamicResource Brush_ToolBarButtonBorder}" />
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Brush_ToolBarMouseOverBackground}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="#FF9A9A9A" />
                <Setter Property="Background" TargetName="GlyphPanel" Value="#EEE9E9" />
                <Setter Property="BorderBrush" TargetName="GlyphPanel" Value="#DBD6D6" />
                <Setter Property="Fill" TargetName="Glyph" Value="#848589" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>


    <Style TargetType="{x:Type MenuItem}">
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template" Value="{StaticResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Padding" Value="7,2,8,3" />
                <Setter Property="Template" Value="{StaticResource {ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Padding" Value="7,2,8,3" />
                <Setter Property="Template" Value="{StaticResource ComponentResourceKey2}" />
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Padding" Value="2,3,2,3" />
                <Setter Property="Template" Value="{StaticResource {ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Padding" Value="2,3,2,3" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Menu}">
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush_DarkBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource Brush_MenuTopLevelTextForeground}" />
    </Style>


</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Karl Shifflett
Architect Gayle Manufacturing Company
United States United States
Karl loves .NET, WPF, WCF, ASP.NET, VB.NET and C#.
 
Awards:
 
  • December 2008 VB.NET Code Project Article Award
  • 2009 Code Project MVP
  • 2008 Code Project MVP
  • 2008 Microsoft MVP - Client App Dev
  • December 2007 VB.NET Code Project Article Award
  • Gold Medal Winner at IBM's 1998 PROIV Programming Contest in Las Vegas
Click here to check out my Blog
 
Click here to learn about Mole 2010 debugging tool for Visual Studio 2010
 
Click here to read about XAML Power Toys
 

Just a grain of sand on the worlds beaches.

Follow on   Twitter

| Advertise | Privacy | Mobile
Web02 | 2.8.141015.1 | Last Updated 2 Apr 2008
Article Copyright 2008 by Karl Shifflett
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid