Skip to content

Commit 91d3449

Browse files
committed
Consolidate Separator styles and remove redundant StatusBar separator brush
Centralizes the MaterialDesignSeparator style into a new resource dictionary and replaces the specific StatusBar.Separator brush with the general separator background brush. This refactor simplifies the theme definitions and ensures consistent separator styling across the StatusBar, Menu, and PopupBox components. The change also updates the StatusBar demo with colored icons and explicit heights to better showcase the UI.
1 parent 651e52a commit 91d3449

File tree

14 files changed

+52
-69
lines changed

14 files changed

+52
-69
lines changed

src/MainDemo.Wpf/StatusBars.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
<smtx:XamlDisplay HorizontalAlignment="Left" UniqueKey="statusbar_2">
3030
<StatusBar>
3131
<StatusBarItem>
32-
<StackPanel Orientation="Horizontal">
32+
<StackPanel Orientation="Horizontal" Height="40">
3333
<materialDesign:PackIcon Kind="CheckCircle"
34+
Foreground="Lime"
3435
VerticalAlignment="Center"
3536
Margin="0,0,4,0" />
3637
<TextBlock Text="Build succeeded" VerticalAlignment="Center" />
@@ -50,7 +51,8 @@
5051
<StackPanel Orientation="Horizontal">
5152
<materialDesign:PackIcon Kind="AlertCircleOutline"
5253
VerticalAlignment="Center"
53-
Margin="0,0,4,0" />
54+
Margin="0,0,4,0"
55+
Foreground="Red"/>
5456
<TextBlock Text="0 Errors" VerticalAlignment="Center" />
5557
</StackPanel>
5658
</StatusBarItem>
@@ -59,7 +61,8 @@
5961
<StackPanel Orientation="Horizontal">
6062
<materialDesign:PackIcon Kind="Alert"
6163
VerticalAlignment="Center"
62-
Margin="0,0,4,0" />
64+
Margin="0,0,4,0"
65+
Foreground="Orange"/>
6366
<TextBlock Text="2 Warnings" VerticalAlignment="Center" />
6467
</StackPanel>
6568
</StatusBarItem>

src/MaterialDesignThemes.Wpf/ResourceDictionaryExtensions.g.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ private static partial void LoadThemeColors(ResourceDictionary resourceDictionar
8686
theme.Separators.Background = GetColor(resourceDictionary, "MaterialDesign.Brush.Separator.Background");
8787
theme.StatusBars.Background = GetColor(resourceDictionary, "MaterialDesign.Brush.StatusBar.Background");
8888
theme.StatusBars.Foreground = GetColor(resourceDictionary, "MaterialDesign.Brush.StatusBar.Foreground");
89-
theme.StatusBars.Separator = GetColor(resourceDictionary, "MaterialDesign.Brush.StatusBar.Separator");
9089
theme.TabControls.Divider = GetColor(resourceDictionary, "MaterialDesign.Brush.TabControl.Divider");
9190
theme.ToolBars.Background = GetColor(resourceDictionary, "MaterialDesign.Brush.ToolBar.Background", "MaterialDesignToolBarBackground");
9291
theme.ToolBars.Separator = GetColor(resourceDictionary, "MaterialDesign.Brush.ToolBar.Separator");
@@ -232,7 +231,6 @@ private static partial void ApplyThemeColors(ResourceDictionary resourceDictiona
232231
SetSolidColorBrush(resourceDictionary, "MaterialDesign.Brush.Separator.Background", theme.Separators.Background);
233232
SetSolidColorBrush(resourceDictionary, "MaterialDesign.Brush.StatusBar.Background", theme.StatusBars.Background);
234233
SetSolidColorBrush(resourceDictionary, "MaterialDesign.Brush.StatusBar.Foreground", theme.StatusBars.Foreground);
235-
SetSolidColorBrush(resourceDictionary, "MaterialDesign.Brush.StatusBar.Separator", theme.StatusBars.Separator);
236234
SetSolidColorBrush(resourceDictionary, "MaterialDesign.Brush.TabControl.Divider", theme.TabControls.Divider);
237235
SetSolidColorBrush(resourceDictionary, "MaterialDesign.Brush.ToolBar.Background", theme.ToolBars.Background);
238236
SetSolidColorBrush(resourceDictionary, "MaterialDesignToolBarBackground", theme.ToolBars.Background);

src/MaterialDesignThemes.Wpf/Theme.g.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -828,13 +828,6 @@ public ColorReference Foreground
828828
set => _foreground = value;
829829
}
830830

831-
private ColorReference _separator;
832-
public ColorReference Separator
833-
{
834-
get => _theme.Resolve(_separator);
835-
set => _separator = value;
836-
}
837-
838831
}
839832

840833
public class TabControl

src/MaterialDesignThemes.Wpf/ThemeExtensions.g.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public static partial void SetLightTheme(this Theme theme)
9191
theme.Separators.Background = BaseThemeColors.Neutral800;
9292
theme.StatusBars.Background = BaseThemeColors.Neutral900;
9393
theme.StatusBars.Foreground = BaseThemeColors.Black900;
94-
theme.StatusBars.Separator = BaseThemeColors.Black100;
9594
theme.TabControls.Divider = BaseThemeColors.Black100;
9695
theme.ToolBars.Background = BaseThemeColors.Neutral900;
9796
theme.ToolBars.Separator = BaseThemeColors.Black100;
@@ -183,7 +182,6 @@ public static partial void SetDarkTheme(this Theme theme)
183182
theme.Separators.Background = BaseThemeColors.Neutral400;
184183
theme.StatusBars.Background = BaseThemeColors.Neutral50;
185184
theme.StatusBars.Foreground = BaseThemeColors.White900;
186-
theme.StatusBars.Separator = BaseThemeColors.White100;
187185
theme.TabControls.Divider = BaseThemeColors.White100;
188186
theme.ToolBars.Background = BaseThemeColors.Neutral50;
189187
theme.ToolBars.Separator = BaseThemeColors.White100;

src/MaterialDesignThemes.Wpf/Themes/MaterialDesign2.Defaults.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RichTextBox.xaml" />
3131
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ScrollBar.xaml" />
3232
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ScrollViewer.xaml" />
33+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Separator.xaml" />
3334
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
3435
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Slider.xaml" />
3536
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.StatusBar.xaml" />

src/MaterialDesignThemes.Wpf/Themes/MaterialDesign3.Defaults.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RichTextBox.xaml" />
3939
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ScrollBar.xaml" />
4040
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ScrollViewer.xaml" />
41+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Separator.xaml" />
4142
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
4243
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.StatusBar.xaml" />
4344
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TabControl.xaml" />

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Dark.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
<colors:StaticResource x:Key="MaterialDesign.Brush.SnackBar.MouseOver" ResourceKey="Neutral700" />
7575
<colors:StaticResource x:Key="MaterialDesign.Brush.StatusBar.Background" ResourceKey="Neutral50" />
7676
<colors:StaticResource x:Key="MaterialDesign.Brush.StatusBar.Foreground" ResourceKey="White900" />
77-
<colors:StaticResource x:Key="MaterialDesign.Brush.StatusBar.Separator" ResourceKey="White100" />
7877
<colors:StaticResource x:Key="MaterialDesign.Brush.TabControl.Divider" ResourceKey="White100" />
7978
<colors:StaticResource x:Key="MaterialDesign.Brush.TextBox.DisabledBackground" ResourceKey="White50" />
8079
<colors:StaticResource x:Key="MaterialDesign.Brush.TextBox.FilledBackground" ResourceKey="White100" />

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Light.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
<colors:StaticResource x:Key="MaterialDesign.Brush.SnackBar.MouseOver" ResourceKey="Neutral200" />
7575
<colors:StaticResource x:Key="MaterialDesign.Brush.StatusBar.Background" ResourceKey="Neutral900" />
7676
<colors:StaticResource x:Key="MaterialDesign.Brush.StatusBar.Foreground" ResourceKey="Black900" />
77-
<colors:StaticResource x:Key="MaterialDesign.Brush.StatusBar.Separator" ResourceKey="Black100" />
7877
<colors:StaticResource x:Key="MaterialDesign.Brush.TabControl.Divider" ResourceKey="Black100" />
7978
<colors:StaticResource x:Key="MaterialDesign.Brush.TextBox.DisabledBackground" ResourceKey="Black50" />
8079
<colors:StaticResource x:Key="MaterialDesign.Brush.TextBox.FilledBackground" ResourceKey="Black50" />

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Menu.xaml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
55
<ResourceDictionary.MergedDictionaries>
66
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Font.xaml" />
7+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Separator.xaml" />
78
</ResourceDictionary.MergedDictionaries>
89

910
<ContextMenu x:Key="MaterialDesignDefaultContextMenu" FontFamily="{Binding PlacementTarget.FontFamily, RelativeSource={RelativeSource Self}}">
@@ -30,24 +31,6 @@
3031
</MenuItem>
3132
</ContextMenu>
3233

33-
<Style x:Key="MaterialDesignSeparator" TargetType="{x:Type Separator}">
34-
<Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Separator.Background}" />
35-
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.Separator.Background}" />
36-
<Setter Property="Height" Value="16" />
37-
<Setter Property="MinHeight" Value="1" />
38-
<Setter Property="SnapsToDevicePixels" Value="true" />
39-
<Setter Property="Template">
40-
<Setter.Value>
41-
<ControlTemplate TargetType="{x:Type Separator}">
42-
<Rectangle Height="1"
43-
HorizontalAlignment="Stretch"
44-
VerticalAlignment="Center"
45-
Fill="{TemplateBinding Background}" />
46-
</ControlTemplate>
47-
</Setter.Value>
48-
</Setter>
49-
</Style>
50-
5134
<Style x:Key="MaterialDesignMenuItem"
5235
TargetType="{x:Type MenuItem}"
5336
BasedOn="{x:Null}">

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<ResourceDictionary.MergedDictionaries>
77
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
8-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Menu.xaml" />
8+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Separator.xaml" />
99
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToolTip.xaml" />
1010
</ResourceDictionary.MergedDictionaries>
1111

0 commit comments

Comments
 (0)