Skip to content

Commit

Permalink
Fixes #192 by making Background and BorderBrush of Button and RibbonG…
Browse files Browse the repository at this point in the history
…roupBox styleable
  • Loading branch information
batzen committed Nov 22, 2015
1 parent 7254f02 commit 0c53541
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 83 deletions.
19 changes: 19 additions & 0 deletions Fluent/Controls/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ public bool IsDefinitive

#endregion

#region CornerRadius

/// <summary>
/// Gets or sets the CornerRadius for the element
/// </summary>
public CornerRadius CornerRadius
{
get { return (CornerRadius)this.GetValue(CornerRadiusProperty); }
set { this.SetValue(CornerRadiusProperty, value); }
}

/// <summary>
/// Using a DependencyProperty as the backing store for CornerRadius. This enables animation, styling, binding, etc...
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(Button), new PropertyMetadata(default(CornerRadius)));

#endregion CornerRadius

#endregion

#region Constructors
Expand Down
28 changes: 18 additions & 10 deletions Fluent/Themes/Office2010/Controls/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
<ControlTemplate x:Key="RibbonButtonControlTemplate"
TargetType="{x:Type Fluent:Button}">
<Border x:Name="border"
BorderThickness="1"
CornerRadius="2"
Background="{DynamicResource TransparentBrush}"
BorderBrush="{DynamicResource TransparentBrush}"
CornerRadius="{TemplateBinding CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Height="Auto"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
<Border x:Name="border1"
Height="Auto"
BorderBrush="{DynamicResource TransparentBrush}"
BorderThickness="1"
CornerRadius="2"
Background="{DynamicResource TransparentBrush}">
CornerRadius="{TemplateBinding CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}">
<Grid Height="Auto">
<Rectangle x:Name="rectangle"
StrokeThickness="0"
Expand All @@ -46,8 +46,7 @@
Content="{Binding LargeIcon, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:StaticConverters.ObjectToImageConverter}}"
Width="32"
Margin="3,2,3,1"
SnapsToDevicePixels="True">
</ContentPresenter>
SnapsToDevicePixels="True" />
<Fluent:TwoLineLabel x:Name="controlLabel"
Text="{TemplateBinding Header}"
Style="{DynamicResource TwoLineLabelStyle}"
Expand Down Expand Up @@ -179,6 +178,7 @@
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>

<Style x:Key="RibbonButtonStyle"
TargetType="{x:Type Fluent:Button}">
<Setter Property="Template"
Expand All @@ -189,8 +189,16 @@
Value="Auto" />
<Setter Property="Foreground"
Value="{DynamicResource DefaultFontBrush}" />
<Setter Property="Background"
Value="{DynamicResource TransparentBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource TransparentBrush}" />
<Setter Property="SnapsToDevicePixels"
Value="False" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="CornerRadius"
Value="2" />
<Style.Triggers>
<Trigger Property="Size"
Value="Large">
Expand Down
51 changes: 30 additions & 21 deletions Fluent/Themes/Office2010/Controls/RibbonGroupBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
Value="85" />
<Setter Property="Foreground"
Value="{DynamicResource DefaultFontBrush}" />
<Setter Property="Background"
Value="{DynamicResource TransparentBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource TransparentBrush}" />
<Style.Triggers>
<Trigger Property="State"
Value="QuickAccess">
Expand All @@ -58,18 +62,18 @@
<Border x:Name="PART_ButtonBorder"
BorderThickness="1"
CornerRadius="2"
Background="{DynamicResource TransparentBrush}"
BorderBrush="{DynamicResource TransparentBrush}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Height="Auto"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
d:LayoutOverrides="Width, Height">
<Border x:Name="border1"
Height="Auto"
BorderBrush="{DynamicResource TransparentBrush}"
BorderBrush="{TemplateBinding Background}"
BorderThickness="1"
CornerRadius="2"
Background="{DynamicResource TransparentBrush}">
Background="{TemplateBinding BorderBrush}">
<Grid Height="Auto">
<Rectangle x:Name="rectangle"
StrokeThickness="0"
Expand Down Expand Up @@ -269,6 +273,8 @@
Focusable="False"
IsTabStop="False"
Template="{DynamicResource DialogLauncherButtonControlTemplate}"
Background="{DynamicResource TransparentBrush}"
BorderBrush="{DynamicResource TransparentBrush}"
VerticalAlignment="Bottom"
Icon="{TemplateBinding LauncherIcon}"
Header="{TemplateBinding LauncherText}"
Expand Down Expand Up @@ -423,9 +429,10 @@
</ControlTemplate.Resources>
<Grid x:Name="grid2"
HorizontalAlignment="Stretch">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" />

<Grid Background="#00000000">

<Grid>
<Grid x:Name="hoverGrid"
Background="{DynamicResource GroupHoverBrush}"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -481,6 +488,8 @@
Focusable="False"
IsTabStop="False"
Template="{DynamicResource DialogLauncherButtonControlTemplate}"
Background="{DynamicResource TransparentBrush}"
BorderBrush="{DynamicResource TransparentBrush}"
VerticalAlignment="Bottom"
Icon="{TemplateBinding LauncherIcon}"
Header="{TemplateBinding LauncherText}"
Expand All @@ -504,7 +513,6 @@
Margin="0"
Width="Auto"
Height="Auto"
Background="#00000000"
Visibility="Collapsed"
Grid.RowSpan="2">
<Fluent:TwoLineLabel HorizontalAlignment="Center"
Expand Down Expand Up @@ -716,20 +724,21 @@
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

<ControlTemplate x:Key="DialogLauncherButtonControlTemplate"
TargetType="{x:Type Fluent:Button}">
<Border x:Name="border"
<Border x:Name="outerBorder"
BorderThickness="1"
CornerRadius="1,0,0,0"
Background="{DynamicResource TransparentBrush}"
BorderBrush="{DynamicResource TransparentBrush}">
<Border x:Name="border1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}">
<Border x:Name="innerBorder"
Width="Auto"
Height="Auto"
BorderThickness="1"
CornerRadius="1,0,0,0"
Background="{DynamicResource TransparentBrush}"
BorderBrush="{DynamicResource TransparentBrush}">
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}">
<Image x:Name="image"
Height="Auto"
HorizontalAlignment="Center"
Expand Down Expand Up @@ -767,16 +776,16 @@
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
TargetName="border"
TargetName="outerBorder"
Value="{DynamicResource ButtonPressedOuterBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="border"
TargetName="outerBorder"
Value="{DynamicResource ButtonPressedOuterBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="border1"
TargetName="innerBorder"
Value="{DynamicResource ButtonPressedInnerBorderBrush}" />
<Setter Property="Background"
TargetName="border1"
TargetName="innerBorder"
Value="{DynamicResource ButtonPressedInnerBackgroundBrush}" />
</Trigger>
<MultiTrigger>
Expand All @@ -787,16 +796,16 @@
Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Background"
TargetName="border"
TargetName="outerBorder"
Value="{DynamicResource ButtonHoverOuterBackgroundBrush}" />
<Setter Property="Background"
TargetName="border1"
TargetName="innerBorder"
Value="{DynamicResource ButtonHoverInnerBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="border1"
TargetName="innerBorder"
Value="{DynamicResource ButtonHoverInnerBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="border"
TargetName="outerBorder"
Value="{DynamicResource ButtonHoverOuterBorderBrush}" />
</MultiTrigger>
</ControlTemplate.Triggers>
Expand Down
17 changes: 12 additions & 5 deletions Fluent/Themes/Office2013/Controls/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<ControlTemplate x:Key="RibbonButtonControlTemplate"
TargetType="{x:Type Fluent:Button}">
<Border x:Name="border"
Background="{DynamicResource TransparentBrush}"
BorderBrush="{DynamicResource TransparentBrush}"
CornerRadius="{TemplateBinding CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Height="Auto"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
Expand Down Expand Up @@ -152,8 +154,16 @@
Value="Auto" />
<Setter Property="Foreground"
Value="{DynamicResource DefaultFontBrush}" />
<Setter Property="Background"
Value="{DynamicResource TransparentBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource TransparentBrush}" />
<Setter Property="SnapsToDevicePixels"
Value="False" />
<Setter Property="BorderThickness"
Value="0" />
<Setter Property="CornerRadius"
Value="0" />
<Style.Triggers>
<Trigger Property="Size"
Value="Large">
Expand All @@ -179,9 +189,6 @@
</Style.Triggers>
</Style>

<Style TargetType="{x:Type Fluent:Button}"
BasedOn="{StaticResource RibbonButtonStyle}" />

<Style x:Key="IronicallyNamedChromelessButtonStyle"
TargetType="{x:Type Button}">
<Setter Property="Background"
Expand Down
Loading

0 comments on commit 0c53541

Please sign in to comment.