Skip to content

Commit ac69333

Browse files
committed
simplify shadows...bit easier to test now i have the palette selector built in. and they didnt work with dynamic base/light switching. bonus is we can freeze them now and use static resources
1 parent 4d3c7f6 commit ac69333

10 files changed

+43
-40
lines changed

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
<!-- set up default styles for our custom Material Design in XAML Toolkit controls -->
2222
<Style TargetType="{x:Type local:Clock}" BasedOn="{StaticResource MaterialDesignClock}" />
2323
<Style TargetType="{x:Type local:TimePicker}" BasedOn="{StaticResource MaterialDesignTimePicker}" />
24-
25-
<!-- TODO freeze, share, theme -->
26-
<SolidColorBrush x:Key="AttentionToActionBrush" Color="Black" Opacity="1" />
27-
24+
2825
<converters:BrushToRadialGradientBrushConverter x:Key="BrushToRadialGradientBrushConverter" />
2926

3027
<Style TargetType="{x:Type local:VisualFeedbackContentControl}">

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Button.xaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
3+
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
4+
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
5+
6+
<ResourceDictionary.MergedDictionaries>
7+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
8+
</ResourceDictionary.MergedDictionaries>
49

510
<Style x:Key="FocusVisual">
611
<Setter Property="Control.Template">
@@ -11,9 +16,8 @@
1116
</Setter.Value>
1217
</Setter>
1318
</Style>
14-
15-
<!-- TODO freeze, share, theme -->
16-
<SolidColorBrush x:Key="AttentionToActionBrush" Color="Black" Opacity=".23" />
19+
20+
<SolidColorBrush x:Key="AttentionToActionBrush" Color="{StaticResource MaterialDesignShadow}" Opacity=".23" po:Freeze="True" />
1721

1822
<Style x:Key="MaterialDesignRaisedButton" TargetType="{x:Type Button}">
1923
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
@@ -30,7 +34,7 @@
3034
<Setter.Value>
3135
<ControlTemplate TargetType="{x:Type Button}">
3236
<Grid>
33-
<Border Background="{TemplateBinding Background}" Effect="{DynamicResource MaterialDesignShadowDepth1}" />
37+
<Border Background="{TemplateBinding Background}" Effect="{StaticResource MaterialDesignShadowDepth1}" />
3438
<Border Background="{TemplateBinding Background}" x:Name="border" CornerRadius="2">
3539
<wpf:VisualFeedbackContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
3640
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Card.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
44
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters">
55

6+
<ResourceDictionary.MergedDictionaries>
7+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
8+
</ResourceDictionary.MergedDictionaries>
9+
610
<converters:CardClipConverter x:Key="CardClipConverter" />
711

812
<ControlTemplate TargetType="{x:Type wpf:Card}" x:Key="CardTemplate">
913
<Border Margin="{TemplateBinding Margin}"
10-
Effect="{DynamicResource MaterialDesignShadowDepth2}"
14+
Effect="{StaticResource MaterialDesignShadowDepth2}"
1115
CornerRadius="{TemplateBinding UniformCornerRadius}" Background="Transparent">
1216
<Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"
1317
x:Name="PART_ClipBorder"

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
44
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters">
55

6+
<ResourceDictionary.MergedDictionaries>
7+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
8+
</ResourceDictionary.MergedDictionaries>
9+
610
<converters:TextFieldHintVisibilityConverter x:Key="TextFieldHintVisibilityConverter" />
711

812
<Style x:Key="FocusVisual">
@@ -154,7 +158,7 @@
154158
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
155159
<Border x:Name="shadow" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
156160
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
157-
BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}" Effect="{DynamicResource MaterialDesignShadowDepth2}">
161+
BorderThickness="1" BorderBrush="{DynamicResource MaterialDesignDivider}" Effect="{StaticResource MaterialDesignShadowDepth2}">
158162
<Border x:Name="dropDownBorder" Background="Transparent">
159163
<ScrollViewer x:Name="DropDownScrollViewer">
160164
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
@@ -237,7 +241,7 @@
237241
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
238242
<Border x:Name="dropDownBorder" BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="1" Background="{DynamicResource MaterialDesignPaper}"
239243
CornerRadius="2"
240-
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" Effect="{DynamicResource MaterialDesignShadowDepth2}">
244+
MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" Effect="{StaticResource MaterialDesignShadowDepth2}">
241245
<ScrollViewer x:Name="DropDownScrollViewer">
242246
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
243247
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Dark.xaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,4 @@
1717
<SolidColorBrush x:Key="MaterialDesignDivider" Color="#616161" />
1818
<SolidColorBrush x:Key="MaterialDesignSelection" Color="#757575" />
1919

20-
<Color x:Key="MaterialDesignShadow1">#AA000000</Color>
21-
<Color x:Key="MaterialDesignShadow2">#AA000000</Color>
22-
<Color x:Key="MaterialDesignShadow3">#AA000000</Color>
23-
<Color x:Key="MaterialDesignShadow4">#AA000000</Color>
24-
<Color x:Key="MaterialDesignShadow5">#AA000000</Color>
25-
2620
</ResourceDictionary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
<ResourceDictionary.MergedDictionaries>
77
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.checkbox.xaml" />
8-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
8+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
9+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
910
</ResourceDictionary.MergedDictionaries>
1011

1112
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
@@ -58,7 +59,7 @@
5859
PopupAnimation="Fade">
5960
<Border Padding="16" Background="{DynamicResource MaterialDesignPaper}" CornerRadius="2"
6061
Margin="5,5,5,5"
61-
BorderBrush="{DynamicResource MaterialDesignDivider}" Effect="{DynamicResource MaterialDesignShadowDepth2}"
62+
BorderBrush="{DynamicResource MaterialDesignDivider}" Effect="{StaticResource MaterialDesignShadowDepth2}"
6263
BorderThickness="1">
6364
<Grid>
6465
<Grid.RowDefinitions>
@@ -272,8 +273,7 @@
272273
<Setter Property="ValidationErrorTemplate">
273274
<Setter.Value>
274275
<ControlTemplate>
275-
<!-- TODO materia pallete color -->
276-
<TextBlock Foreground="Red" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"/>
276+
<TextBlock Foreground="#d50000" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"/>
277277
</ControlTemplate>
278278
</Setter.Value>
279279
</Setter>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Light.xaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,5 @@
1515

1616
<SolidColorBrush x:Key="MaterialDesignDivider" Color="#FFeeeeee" />
1717
<SolidColorBrush x:Key="MaterialDesignSelection" Color="#FFf5f5f5" />
18-
19-
20-
21-
<Color x:Key="MaterialDesignShadow1">#CCCCCC</Color>
22-
<Color x:Key="MaterialDesignShadow2">#C4C4C4</Color>
23-
<Color x:Key="MaterialDesignShadow3">#BBBBBB</Color>
24-
<Color x:Key="MaterialDesignShadow4">#BBBBBB</Color>
25-
<Color x:Key="MaterialDesignShadow5">#BBBBBB</Color>
2618

2719
</ResourceDictionary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ListBox.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
33

4+
<ResourceDictionary.MergedDictionaries>
5+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
6+
</ResourceDictionary.MergedDictionaries>
7+
48
<Style x:Key="FocusVisual">
59
<Setter Property="Control.Template">
610
<Setter.Value>
@@ -92,7 +96,7 @@
9296
<ControlTemplate TargetType="{x:Type ListBoxItem}">
9397
<Grid>
9498
<Border CornerRadius="2"
95-
Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" Effect="{DynamicResource MaterialDesignShadowDepth2}" />
99+
Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" Effect="{StaticResource MaterialDesignShadowDepth2}" />
96100
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
97101
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"
98102
CornerRadius="2"/>
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
34

45
<!-- thanks: http://marcangers.com/material-design-shadows-in-wpf/ -->
5-
6-
<DropShadowEffect x:Key="MaterialDesignShadowDepth1" BlurRadius="5" ShadowDepth="1" Direction="270" Color="{DynamicResource MaterialDesignShadow1}"/>
7-
<DropShadowEffect x:Key="MaterialDesignShadowDepth2" BlurRadius="8" ShadowDepth="1.5" Direction="270" Color="{DynamicResource MaterialDesignShadow2}"/>
8-
<DropShadowEffect x:Key="MaterialDesignShadowDepth3" BlurRadius="14" ShadowDepth="4.5" Direction="270" Color="{DynamicResource MaterialDesignShadow3}"/>
9-
<DropShadowEffect x:Key="MaterialDesignShadowDepth4" BlurRadius="25" ShadowDepth="8" Direction="270" Color="{DynamicResource MaterialDesignShadow4}"/>
10-
<DropShadowEffect x:Key="MaterialDesignShadowDepth5" BlurRadius="35" ShadowDepth="13" Direction="270" Color="{DynamicResource MaterialDesignShadow5}"/>
6+
7+
<Color x:Key="MaterialDesignShadow">#AA000000</Color>
8+
9+
<DropShadowEffect x:Key="MaterialDesignShadowDepth1" BlurRadius="5" ShadowDepth="1" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" po:Freeze="True" />
10+
<DropShadowEffect x:Key="MaterialDesignShadowDepth2" BlurRadius="8" ShadowDepth="1.5" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" po:Freeze="True" />
11+
<DropShadowEffect x:Key="MaterialDesignShadowDepth3" BlurRadius="14" ShadowDepth="4.5" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" po:Freeze="True" />
12+
<DropShadowEffect x:Key="MaterialDesignShadowDepth4" BlurRadius="25" ShadowDepth="8" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" po:Freeze="True" />
13+
<DropShadowEffect x:Key="MaterialDesignShadowDepth5" BlurRadius="35" ShadowDepth="13" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" po:Freeze="True" />
1114

1215
</ResourceDictionary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ToolBar.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.combobox.xaml" />
88
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Menu.xaml" />
99
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />
10+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" />
1011
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
11-
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.togglebutton.xaml" />
12+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/materialdesigntheme.togglebutton.xaml" />
1213
</ResourceDictionary.MergedDictionaries>
1314

1415
<Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
@@ -130,7 +131,7 @@
130131
<Border x:Name="ToolBarSubMenuBorder" BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="1" Background="{DynamicResource MaterialDesignPaper}"
131132
TextBlock.FontWeight="ExtraBold"
132133
CornerRadius="2" Margin="1"
133-
Effect="{DynamicResource MaterialDesignShadowDepth2}" RenderOptions.ClearTypeHint="Enabled">
134+
Effect="{StaticResource MaterialDesignShadowDepth2}" RenderOptions.ClearTypeHint="Enabled">
134135
<Border Background="Transparent">
135136
<ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel" KeyboardNavigation.DirectionalNavigation="Cycle" FocusVisualStyle="{x:Null}" Focusable="true" Margin="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle" WrapWidth="200"/>
136137
</Border>

0 commit comments

Comments
 (0)