Skip to content

Commit

Permalink
Fix ToggleButton style not showing IsChecked state (#8)
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
gix committed Apr 10, 2022
1 parent 0a3a004 commit f96672b
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 67 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [vNext]
### Fixed
- ToggleButton style does not show IsCheckes state. (#8)

## [0.6.3] - 2021-07-04
### Fixed
- ThemeManager hooking now works on .NET 5+.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<aero10:ButtonChrome Style="{StaticResource {x:Type aero10:ButtonChrome}}"
<aero10:ButtonChrome x:Name="ButtonChrome"
Style="{StaticResource {x:Type aero10:ButtonChrome}}"
Focusable="False"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand All @@ -485,6 +486,11 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="ButtonChrome" Property="RenderPressed" Value="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ResourceDictionary
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
Expand Down Expand Up @@ -479,7 +479,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<aero8:ButtonChrome Style="{StaticResource {x:Type aero8:ButtonChrome}}"
<aero8:ButtonChrome x:Name="ButtonChrome"
Style="{StaticResource {x:Type aero8:ButtonChrome}}"
Focusable="False"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand All @@ -494,6 +495,11 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="ButtonChrome" Property="RenderPressed" Value="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<aero10:ButtonChrome Style="{StaticResource {x:Type aero10:ButtonChrome}}"
<aero10:ButtonChrome x:Name="ButtonChrome"
Style="{StaticResource {x:Type aero10:ButtonChrome}}"
Focusable="False"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand All @@ -387,6 +388,11 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="ButtonChrome" Property="RenderPressed" Value="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<aero8:ButtonChrome Style="{StaticResource {x:Type aero8:ButtonChrome}}"
<aero8:ButtonChrome x:Name="ButtonChrome"
Style="{StaticResource {x:Type aero8:ButtonChrome}}"
Focusable="False"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand All @@ -387,6 +388,11 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="ButtonChrome" Property="RenderPressed" Value="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<aero10:ButtonChrome Style="{StaticResource {x:Type aero10:ButtonChrome}}"
<aero10:ButtonChrome x:Name="ButtonChrome"
Style="{StaticResource {x:Type aero10:ButtonChrome}}"
Focusable="False"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand All @@ -377,6 +378,11 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="ButtonChrome" Property="RenderPressed" Value="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<aero8:ButtonChrome Style="{StaticResource {x:Type aero8:ButtonChrome}}"
<aero8:ButtonChrome x:Name="ButtonChrome"
Style="{StaticResource {x:Type aero8:ButtonChrome}}"
Focusable="False"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand All @@ -377,6 +378,11 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
<ControlTemplate.Triggers>
<Trigger Property="ToggleButton.IsChecked" Value="True">
<Setter TargetName="ButtonChrome" Property="RenderPressed" Value="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
137 changes: 77 additions & 60 deletions Source/ThemePreviewer/Samples/ButtonSampleNative.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Source/ThemePreviewer/Samples/ButtonSampleWpf.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="6,1"/>
</Style>
<Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
<Setter Property="MinWidth" Value="75"/>
<Setter Property="MinHeight" Value="23"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="6,1"/>
</Style>
</UserControl.Resources>
<Grid Margin="3">
<StackPanel>
Expand All @@ -20,6 +26,7 @@
<Button Content="Button" Margin="0,0,0,6" HorizontalAlignment="Left"/>
<Button x:Name="defaulted" Content="Default" IsDefault="True" Margin="0,0,0,6" HorizontalAlignment="Left"/>
<Button Content="Disabled" IsEnabled="False" Margin="0,0,0,6" HorizontalAlignment="Left"/>
<ToggleButton Content="Toggled" IsChecked="True" HorizontalAlignment="Left" Margin="0,0,0,6"/>
</StackPanel>
<StackPanel Margin="22,0,0,0">
<Button x:Name="normalChrome" Margin="0,0,0,6" HorizontalAlignment="Left" IsHitTestVisible="False"/>
Expand Down

0 comments on commit f96672b

Please sign in to comment.