mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-09 17:41:14 +10:00
fix(dns): scope leaked ToggleButton style and theme the ComboBox dropdown popup (#4835)
Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
@@ -271,6 +271,27 @@ Describe "XAML document" {
|
||||
}
|
||||
}
|
||||
|
||||
It "scopes toggle button styles without leaking into combo boxes" {
|
||||
$resources = $script:xaml.SelectSingleNode('//*[local-name()="Window.Resources"]')
|
||||
$implicitToggleStyles = @($resources.SelectNodes('./*[local-name()="Style"][@TargetType="ToggleButton" or @TargetType="{x:Type ToggleButton}"][not(@x:Key)]', $script:xamlNamespace))
|
||||
$tabStyle = $resources.SelectSingleNode('./*[local-name()="Style"][@x:Key="TabToggleButton"]', $script:xamlNamespace)
|
||||
$comboToggleStyle = $resources.SelectSingleNode('./*[local-name()="Style"][@x:Key="ComboBoxToggleButtonStyle"]', $script:xamlNamespace)
|
||||
$comboStyle = $resources.SelectSingleNode('./*[local-name()="Style"][@TargetType="ComboBox"]')
|
||||
$comboToggle = $comboStyle.SelectSingleNode('.//*[local-name()="ToggleButton"][@Name="ToggleButton"]')
|
||||
$comboItemStyle = $resources.SelectSingleNode('./*[local-name()="Style"][@TargetType="ComboBoxItem"]')
|
||||
$navButtons = @($script:xaml.SelectNodes('//*[local-name()="StackPanel"][@Name="NavDockPanel"]/*[local-name()="ToggleButton"]'))
|
||||
|
||||
$implicitToggleStyles | Should -BeNullOrEmpty
|
||||
$tabStyle | Should -Not -BeNullOrEmpty
|
||||
$comboToggleStyle | Should -Not -BeNullOrEmpty
|
||||
$comboToggle.GetAttribute("Style") | Should -Be "{StaticResource ComboBoxToggleButtonStyle}"
|
||||
$comboItemStyle | Should -Not -BeNullOrEmpty
|
||||
$navButtons.Count | Should -Be 5
|
||||
foreach ($navButton in $navButtons) {
|
||||
$navButton.GetAttribute("Style") | Should -Be "{StaticResource TabToggleButton}"
|
||||
}
|
||||
}
|
||||
|
||||
It "uses state-aware maximize and restore icons" {
|
||||
$themes = Get-WinUtilConfigObject -Name "themes"
|
||||
$minimizeButton = $script:xaml.SelectSingleNode('//*[local-name()="Button"][@Name="WPFMinimizeButton"]')
|
||||
|
||||
+39
-7
@@ -248,6 +248,17 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="ComboBoxToggleButtonStyle" TargetType="ToggleButton">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0">
|
||||
<ContentPresenter/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundColor}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundColor}" />
|
||||
@@ -262,6 +273,7 @@
|
||||
CornerRadius="{DynamicResource ButtonCornerRadius}"
|
||||
Background="{TemplateBinding Background}">
|
||||
<ToggleButton Name="ToggleButton"
|
||||
Style="{StaticResource ComboBoxToggleButtonStyle}"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
@@ -309,6 +321,27 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBoxBackgroundColor}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundColor}"/>
|
||||
<Setter Property="Padding" Value="6,3"/>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" Background="Transparent"
|
||||
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ComboBoxItem}}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsHighlighted" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundMouseoverColor}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundSelectedColor}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="Label">
|
||||
<Setter Property="Foreground" Value="{DynamicResource LabelboxForegroundColor}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource LabelBackgroundColor}"/>
|
||||
@@ -321,8 +354,7 @@
|
||||
<Setter Property="Foreground" Value="{DynamicResource LabelboxForegroundColor}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource LabelBackgroundColor}"/>
|
||||
</Style>
|
||||
<!-- Toggle button template x:Key="TabToggleButton" -->
|
||||
<Style TargetType="{x:Type ToggleButton}">
|
||||
<Style x:Key="TabToggleButton" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Margin" Value="{DynamicResource ButtonMargin}"/>
|
||||
<Setter Property="Content" Value=""/>
|
||||
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}"/>
|
||||
@@ -958,7 +990,7 @@
|
||||
<StackPanel Name="NavDockPanel" Orientation="Horizontal" Grid.Column="0" VerticalAlignment="Center" Margin="5,5,10,5">
|
||||
<StackPanel Name="NavLogoPanel" Orientation="Horizontal" HorizontalAlignment="Left" Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True" Margin="10,0,20,0">
|
||||
</StackPanel>
|
||||
<ToggleButton Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
<ToggleButton Style="{StaticResource TabToggleButton}" Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
Background="{DynamicResource ButtonInstallBackgroundColor}" Foreground="white" FontWeight="Bold" Name="WPFTab1BT">
|
||||
<ToggleButton.Content>
|
||||
<TextBlock FontSize="{DynamicResource TabButtonFontSize}" Background="Transparent" Foreground="{DynamicResource ButtonInstallForegroundColor}" >
|
||||
@@ -966,7 +998,7 @@
|
||||
</TextBlock>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<ToggleButton Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
<ToggleButton Style="{StaticResource TabToggleButton}" Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
Background="{DynamicResource ButtonTweaksBackgroundColor}" Foreground="{DynamicResource ButtonTweaksForegroundColor}" FontWeight="Bold" Name="WPFTab2BT">
|
||||
<ToggleButton.Content>
|
||||
<TextBlock FontSize="{DynamicResource TabButtonFontSize}" Background="Transparent" Foreground="{DynamicResource ButtonTweaksForegroundColor}">
|
||||
@@ -974,7 +1006,7 @@
|
||||
</TextBlock>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<ToggleButton Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
<ToggleButton Style="{StaticResource TabToggleButton}" Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
Background="{DynamicResource ButtonConfigBackgroundColor}" Foreground="{DynamicResource ButtonConfigForegroundColor}" FontWeight="Bold" Name="WPFTab3BT">
|
||||
<ToggleButton.Content>
|
||||
<TextBlock FontSize="{DynamicResource TabButtonFontSize}" Background="Transparent" Foreground="{DynamicResource ButtonConfigForegroundColor}">
|
||||
@@ -982,7 +1014,7 @@
|
||||
</TextBlock>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<ToggleButton Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
<ToggleButton Style="{StaticResource TabToggleButton}" Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="{DynamicResource TabButtonWidth}"
|
||||
Background="{DynamicResource ButtonUpdatesBackgroundColor}" Foreground="{DynamicResource ButtonUpdatesForegroundColor}" FontWeight="Bold" Name="WPFTab4BT">
|
||||
<ToggleButton.Content>
|
||||
<TextBlock FontSize="{DynamicResource TabButtonFontSize}" Background="Transparent" Foreground="{DynamicResource ButtonUpdatesForegroundColor}">
|
||||
@@ -990,7 +1022,7 @@
|
||||
</TextBlock>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<ToggleButton Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="Auto" MinWidth="{DynamicResource TabButtonWidth}"
|
||||
<ToggleButton Style="{StaticResource TabToggleButton}" Margin="0,0,5,0" Height="{DynamicResource TabButtonHeight}" Width="Auto" MinWidth="{DynamicResource TabButtonWidth}"
|
||||
Background="{DynamicResource ButtonWin11ISOBackgroundColor}" Foreground="{DynamicResource ButtonWin11ISOForegroundColor}" FontWeight="Bold" Name="WPFTab5BT">
|
||||
<ToggleButton.Content>
|
||||
<TextBlock FontSize="{DynamicResource TabButtonFontSize}" Background="Transparent" Foreground="{DynamicResource ButtonWin11ISOForegroundColor}">
|
||||
|
||||
Reference in New Issue
Block a user