Skip to content

Commit d7c0f22

Browse files
authored
Fixing the underline behavior of the numeric up down control (#1547)
1 parent d945d2e commit d7c0f22

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

MaterialDesignThemes.MahApps/MaterialDesignAssist.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ public static void SetMahApps(this ResourceDictionary resourceDictionary, ITheme
6969
resourceDictionary.SetBrush("MahApps.Brushes.GrayNormal", (Color)resourceDictionary["MahApps.Colors.GrayNormal"]);
7070
resourceDictionary.SetBrush("MahApps.Brushes.GrayHover", (Color)resourceDictionary["MahApps.Colors.GrayHover"]);
7171

72-
resourceDictionary.SetBrush("MahApps.Brushes.TextBox.Border", (Color)resourceDictionary["MahApps.Colors.Gray6"]);
7372
resourceDictionary.SetBrush("MahApps.Brushes.Controls.Border", (Color)resourceDictionary["MahApps.Colors.Gray6"]);
73+
resourceDictionary.SetBrush("MahApps.Brushes.TextBox.Border", theme.TextBoxBorder);
7474
resourceDictionary.SetBrush("MahApps.Brushes.TextBox.MouseOverInnerBorder", (Color)resourceDictionary["MahApps.Colors.Black"]);
7575
resourceDictionary.SetBrush("MahApps.Brushes.TextBox.FocusBorder", (Color)resourceDictionary["MahApps.Colors.Black"]);
76-
resourceDictionary.SetBrush("MahApps.Brushes.TextBox.MouseOverBorder", (Color)resourceDictionary["MahApps.Colors.Gray2"]);
76+
resourceDictionary.SetBrush("MahApps.Brushes.TextBox.MouseOverBorder", theme.PrimaryMid.Color);
7777

7878
resourceDictionary.SetBrush("MahApps.Brushes.Button.MouseOverBorder", (Color)resourceDictionary["MahApps.Colors.Black"]);
7979
resourceDictionary.SetBrush("MahApps.Brushes.Button.MouseOverInnerBorder", (Color)resourceDictionary["MahApps.Colors.Black"]);

MaterialDesignThemes.MahApps/Themes/MaterialDesignTheme.MahApps.NumericUpDown.xaml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
33
xmlns:mahShared="http://metro.mahapps.com/winfx/xaml/shared"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes">
5+
xmlns:mdix="http://materialdesigninxaml.net/winfx/xaml/themes">
66
<ResourceDictionary.MergedDictionaries>
77
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ValidationErrorTemplate.xaml" />
88
</ResourceDictionary.MergedDictionaries>
@@ -12,7 +12,7 @@
1212
<Style TargetType="{x:Type mah:NumericUpDown}" x:Key="MaterialDesignNumericUpDown">
1313
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Control.Background}" />
1414
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.TextBox.Border}" />
15-
<Setter Property="BorderThickness" Value="1" />
15+
<Setter Property="BorderThickness" Value="0 0 0 1"/>
1616
<Setter Property="ContextMenu" Value="{DynamicResource MahApps.TextBox.ContextMenu}" />
1717
<Setter Property="mah:ControlsHelper.FocusBorderBrush" Value="{DynamicResource MahApps.Brushes.TextBox.FocusBorder}" />
1818
<Setter Property="mah:ControlsHelper.MouseOverBorderBrush" Value="{DynamicResource MahApps.Brushes.TextBox.MouseOverBorder}" />
@@ -31,6 +31,7 @@
3131
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
3232
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
3333
<Setter Property="SnapsToDevicePixels" Value="true" />
34+
<Setter Property="mdix:TextFieldAssist.UnderlineBrush" Value="{DynamicResource PrimaryHueMidBrush}" />
3435
<Setter Property="Template">
3536
<Setter.Value>
3637
<ControlTemplate TargetType="{x:Type mah:NumericUpDown}">
@@ -47,8 +48,13 @@
4748
<ColumnDefinition x:Name="PART_MiddleColumn" Width="Auto" />
4849
<ColumnDefinition x:Name="PART_RightColumn" Width="Auto" />
4950
</Grid.ColumnDefinitions>
51+
<Grid.RowDefinitions>
52+
<RowDefinition />
53+
<RowDefinition Height="Auto" />
54+
</Grid.RowDefinitions>
5055
<TextBox x:Name="PART_TextBox"
5156
Grid.Column="0"
57+
Grid.Row="0"
5258
MinWidth="20"
5359
MinHeight="0"
5460
Margin="0"
@@ -71,7 +77,7 @@
7177
mah:TextBoxHelper.Watermark="{TemplateBinding mah:TextBoxHelper.Watermark}"
7278
mah:TextBoxHelper.WatermarkAlignment="{TemplateBinding mah:TextBoxHelper.WatermarkAlignment}"
7379
mah:TextBoxHelper.WatermarkTrimming="{TemplateBinding mah:TextBoxHelper.WatermarkTrimming}"
74-
materialDesign:TextFieldAssist.DecorationVisibility="Collapsed"
80+
mdix:TextFieldAssist.DecorationVisibility="Collapsed"
7581
Background="{x:Null}"
7682
BorderThickness="0"
7783
ContextMenu="{TemplateBinding ContextMenu}"
@@ -88,6 +94,7 @@
8894
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
8995
<RepeatButton x:Name="PART_NumericUp"
9096
Grid.Column="1"
97+
Grid.Row="0"
9198
Width="{TemplateBinding UpDownButtonsWidth}"
9299
Margin="0"
93100
Delay="{TemplateBinding Delay}"
@@ -104,6 +111,7 @@
104111
</RepeatButton>
105112
<RepeatButton x:Name="PART_NumericDown"
106113
Grid.Column="2"
114+
Grid.Row="0"
107115
Width="{TemplateBinding UpDownButtonsWidth}"
108116
Margin="0"
109117
VerticalContentAlignment="Center"
@@ -119,6 +127,15 @@
119127
Fill="{DynamicResource MahApps.Brushes.Gray1}"
120128
Stretch="Fill" />
121129
</RepeatButton>
130+
131+
<mdix:Underline
132+
x:Name="Underline"
133+
Grid.Column="0"
134+
Grid.Row="1"
135+
Grid.ColumnSpan="3"
136+
Visibility="{Binding Path=(mdix:TextFieldAssist.DecorationVisibility), RelativeSource={RelativeSource TemplatedParent}}"
137+
CornerRadius="{Binding Path=(mdix:TextFieldAssist.UnderlineCornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
138+
Background="{Binding Path=(mdix:TextFieldAssist.UnderlineBrush), RelativeSource={RelativeSource TemplatedParent}}" />
122139
</Grid>
123140
<Border x:Name="DisabledVisualElement"
124141
Background="{DynamicResource MahApps.Brushes.Controls.Disabled}"
@@ -227,12 +244,15 @@
227244
<Setter TargetName="PART_NumericDown" Property="Background" Value="{DynamicResource MahApps.Brushes.Black}" />
228245
<Setter TargetName="PolygonDown" Property="Fill" Value="{DynamicResource MahApps.Brushes.White}" />
229246
</Trigger>
230-
<Trigger Property="IsMouseOver" Value="true">
247+
<Trigger Property="IsMouseOver" Value="True">
231248
<Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ControlsHelper.MouseOverBorderBrush)}" />
232249
</Trigger>
233-
<Trigger SourceName="PART_TextBox" Property="IsFocused" Value="true">
250+
<Trigger SourceName="PART_TextBox" Property="IsFocused" Value="True">
234251
<Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ControlsHelper.FocusBorderBrush)}" />
235252
</Trigger>
253+
<Trigger Property="IsKeyboardFocusWithin" Value="True">
254+
<Setter TargetName="Underline" Property="IsActive" Value="True"/>
255+
</Trigger>
236256
<Trigger Property="HideUpDownButtons" Value="True">
237257
<Setter TargetName="PART_NumericDown" Property="Visibility" Value="Collapsed" />
238258
<Setter TargetName="PART_NumericUp" Property="Visibility" Value="Collapsed" />

0 commit comments

Comments
 (0)