Skip to content

Commit

Permalink
Fixes #400 by no longer overwriting default control styles globally
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Feb 18, 2017
1 parent 9232bd4 commit 6d86c6e
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 292 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
- `SelectedContentMargin` was added to `BackstageTabControl`
- `QuickAccessToolBarHeight` on `Ribbon`
- `TitleBarHeight` on `RibbonWindow`
- [#400](../../issues/400) - Default menu / menuitem appearance overridden by FluentRibbon
- Styles for the following types are no longer overwritten globally `ContextMenu`, `MenuItem`, `MenuItem.SeparatorStyleKey`, `StatusBar`, `StatusBarItem`, `StatusBar.SeparatorStyleKey`
- `MenuItemStyle` is renamed to `FluentDefaultSystemMenuItemStyle`

- ### Bug fixes
- [#288](../../issues/288) - Fluent:DropDownButton Background can't be changed
Expand Down
14 changes: 11 additions & 3 deletions Fluent.Ribbon/Themes/Common.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Fluent="clr-namespace:Fluent">
<!-- Set default controls -->
<Style TargetType="Fluent:Spinner"
<Style TargetType="{x:Type Fluent:Spinner}"
BasedOn="{StaticResource SpinnerStyle}" />
<Style TargetType="Fluent:TwoLineLabel"
<Style TargetType="{x:Type Fluent:TwoLineLabel}"
BasedOn="{StaticResource TwoLineLabelStyle}" />
<Style TargetType="Fluent:KeyTip"
<Style TargetType="{x:Type Fluent:KeyTip}"
BasedOn="{StaticResource KeyTipStyle}" />
<Style TargetType="{x:Type Fluent:ScreenTip}"
BasedOn="{StaticResource ScreenTipStyle}" />
Expand Down Expand Up @@ -55,4 +55,12 @@
BasedOn="{StaticResource RibbonStyle}" />
<Style TargetType="{x:Type Fluent:RibbonWindow}"
BasedOn="{StaticResource RibbonWindowStyle}" />

<Style TargetType="{x:Type Fluent:MenuItem}"
BasedOn="{StaticResource FluentDefaultSystemMenuItemStyle}" />
<Style BasedOn="{StaticResource RibbonStatusBarItemStyle}"
TargetType="{x:Type Fluent:StatusBarItem}" />
<Style x:Key="{x:Type Fluent:GroupSeparatorMenuItem}"
TargetType="{x:Type Fluent:GroupSeparatorMenuItem}"
BasedOn="{StaticResource MenuGroupSeparatorStyle}" />
</ResourceDictionary>
4 changes: 2 additions & 2 deletions Fluent.Ribbon/Themes/Controls/ApplicationMenuItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
BasedOn="{StaticResource MenuScrollViewer}" />
<Style x:Key="{x:Type Fluent:MenuItem}"
TargetType="{x:Type Fluent:MenuItem}"
BasedOn="{StaticResource MenuItemStyle}" />
BasedOn="{StaticResource FluentDefaultSystemMenuItemStyle}" />
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Expand Down Expand Up @@ -512,7 +512,7 @@
BasedOn="{StaticResource MenuScrollViewer}" />
<Style x:Key="{x:Type Fluent:MenuItem}"
TargetType="{x:Type Fluent:MenuItem}"
BasedOn="{StaticResource MenuItemStyle}" />
BasedOn="{StaticResource FluentDefaultSystemMenuItemStyle}" />
</ResourceDictionary>
</ControlTemplate.Resources>
<Grid Width="Auto"
Expand Down
4 changes: 2 additions & 2 deletions Fluent.Ribbon/Themes/Controls/KeyTip.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mc:Ignorable="d">

<Style x:Key="KeyTipStyle"
TargetType="Fluent:KeyTip">
TargetType="{x:Type Fluent:KeyTip}">
<Setter Property="Foreground"
Value="White" />
<Setter Property="Background"
Expand All @@ -17,7 +17,7 @@
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Fluent:KeyTip">
<ControlTemplate TargetType="{x:Type Fluent:KeyTip}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
Expand Down
20 changes: 2 additions & 18 deletions Fluent.Ribbon/Themes/Controls/Menu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Setter Property="VerticalAlignment"
Value="Top" />
</Style>

<ControlTemplate x:Key="FluentPopupMenuControlTemplate"
TargetType="{x:Type Fluent:ContextMenu}">
<ControlTemplate.Resources>
Expand Down Expand Up @@ -135,24 +135,8 @@
</ControlTemplate.Triggers>
</ControlTemplate>

<!-- Default menu style for wpf context menu-->

<Style TargetType="{x:Type ContextMenu}">
<Setter Property="Template"
Value="{DynamicResource PopupMenuControlTemplate}" />
<Setter Property="Foreground"
Value="{DynamicResource DefaultFontBrush}" />
<Setter Property="MinWidth"
Value="0" />
<Setter Property="MinHeight"
Value="0" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="VerticalAlignment"
Value="Top" />
</Style>
<ControlTemplate x:Key="PopupMenuControlTemplate"
TargetType="{x:Type ContextMenu}">
TargetType="{x:Type Fluent:ContextMenu}">
<ControlTemplate.Resources>
<Style BasedOn="{StaticResource MenuSeparatorStyle}"
TargetType="{x:Type Separator}" />
Expand Down
9 changes: 4 additions & 5 deletions Fluent.Ribbon/Themes/Controls/MenuItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
Height="2" />
</Grid>
</ControlTemplate>

<ControlTemplate x:Key="ResizeVerticalThumbControlTemplate"
TargetType="{x:Type Thumb}">
<Grid Background="#00000000">
Expand Down Expand Up @@ -276,6 +277,7 @@
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

<!--Header Menu Item Template-->
<ControlTemplate x:Key="HeaderMenuItemTemplate"
TargetType="{x:Type MenuItem}">
Expand Down Expand Up @@ -527,6 +529,7 @@
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

<!--Splited Menu Item Template-->
<ControlTemplate x:Key="SplitedMenuItemTemplate"
TargetType="{x:Type MenuItem}">
Expand Down Expand Up @@ -829,7 +832,7 @@
</ControlTemplate>

<!--Menu Item Style-->
<Style x:Key="MenuItemStyle"
<Style x:Key="FluentDefaultSystemMenuItemStyle"
TargetType="{x:Type MenuItem}">
<Setter Property="ScrollViewer.VerticalScrollBarVisibility"
Value="Auto" />
Expand Down Expand Up @@ -866,8 +869,4 @@
</MultiTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type MenuItem}"
BasedOn="{StaticResource MenuItemStyle}" />
<Style TargetType="{x:Type Fluent:MenuItem}"
BasedOn="{StaticResource {x:Type MenuItem}}" />
</ResourceDictionary>
12 changes: 3 additions & 9 deletions Fluent.Ribbon/Themes/Controls/MenuSeparator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Fluent="clr-namespace:Fluent"
mc:Ignorable="d">

<Style x:Key="MenuSeparatorStyle"
TargetType="{x:Type Separator}">
<Setter Property="Template"
Value="{DynamicResource MenuSeparatorControlTemplate}" />
</Style>
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
TargetType="{x:Type Separator}">
<Setter Property="Template"
Value="{DynamicResource MenuSeparatorControlTemplate}" />
</Style>

<ControlTemplate x:Key="MenuSeparatorControlTemplate"
TargetType="{x:Type Separator}">
<Grid Height="Auto">
Expand All @@ -28,11 +23,13 @@
Data="M0,0L1,0" />
</Grid>
</ControlTemplate>

<Style x:Key="MenuGroupSeparatorStyle"
TargetType="{x:Type Fluent:GroupSeparatorMenuItem}">
<Setter Property="Template"
Value="{DynamicResource MenuGroupSeparatorControlTemplate}" />
</Style>

<ControlTemplate x:Key="MenuGroupSeparatorControlTemplate"
TargetType="{x:Type Fluent:GroupSeparatorMenuItem}">
<Grid Height="Auto"
Expand All @@ -46,7 +43,4 @@
FontWeight="Bold" />
</Grid>
</ControlTemplate>
<Style x:Key="{x:Type Fluent:GroupSeparatorMenuItem}"
TargetType="{x:Type Fluent:GroupSeparatorMenuItem}"
BasedOn="{StaticResource MenuGroupSeparatorStyle}" />
</ResourceDictionary>
9 changes: 8 additions & 1 deletion Fluent.Ribbon/Themes/Controls/Ribbon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
mc:Ignorable="d">
<ControlTemplate x:Key="RibbonControlTemplate"
TargetType="{x:Type Fluent:Ribbon}">
<Grid x:Name="PART_LayoutRoot"
<ControlTemplate.Resources>
<Style BasedOn="{StaticResource MenuSeparatorStyle}"
TargetType="{x:Type Separator}" />
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
BasedOn="{StaticResource MenuSeparatorStyle}"
TargetType="{x:Type Separator}" />
</ControlTemplate.Resources>
<Grid x:Name="PART_LayoutRoot"
Width="Auto"
Height="Auto">
<Grid.RowDefinitions>
Expand Down
Loading

0 comments on commit 6d86c6e

Please sign in to comment.