Skip to content

Commit 41489ff

Browse files
Align NumericUpDown style with other controls (#3615)
* Add NumericUpDown to FieldsLineUp * Align NumericUpDown style to other controls * Respect values for IncreaseContent and DecreaseContent * Add NumericUpDown to Material2 FieldsLineUp * Rename PART_TextBox * Fixing obsolete message on assist classes. * Updated NumericUpDown styles to not leverage obsolete attached properties. * Fixing UI tests --------- Co-authored-by: Kevin Bost <[email protected]>
1 parent 5e856ef commit 41489ff

File tree

13 files changed

+227
-57
lines changed

13 files changed

+227
-57
lines changed

src/MainDemo.Wpf/Domain/MainWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private static IEnumerable<DemoItem> GenerateDemoItems(ISnackbarMessageQueue sna
191191
};
192192

193193
yield return new DemoItem(
194-
"Field line up",
194+
"Fields line up",
195195
typeof(FieldsLineUp),
196196
new[]
197197
{

src/MainDemo.Wpf/FieldsLineUp.xaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
<GroupBox HorizontalAlignment="Left"
2121
VerticalAlignment="Top"
22-
materialDesign:ColorZoneAssist.Background="{DynamicResource PrimaryHueLightBrush}"
23-
materialDesign:ColorZoneAssist.Foreground="{DynamicResource PrimaryHueLightForegroundBrush}"
22+
BorderBrush="{DynamicResource MaterialDesign.Brush.Primary}"
23+
BorderThickness="1"
24+
materialDesign:ColorZoneAssist.Background="{DynamicResource MaterialDesign.Brush.Background}"
25+
materialDesign:ColorZoneAssist.Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
2426
materialDesign:ColorZoneAssist.Mode="Custom">
2527
<GroupBox.Header>
2628
<StackPanel Orientation="Horizontal">
@@ -81,7 +83,7 @@
8183
<Style TargetType="TextBox" BasedOn="{StaticResource MaterialDesignTextBox}">
8284
<Setter Property="FontFamily" Value="Consolas" />
8385
<Setter Property="HorizontalAlignment" Value="Left" />
84-
<Setter Property="Margin" Value="10,2" />
86+
<Setter Property="Margin" Value="10,6" />
8587
<Setter Property="MinWidth" Value="200" />
8688
<Setter Property="VerticalAlignment" Value="Center" />
8789
<Setter Property="materialDesign:HintAssist.IsFloating" Value="True" />
@@ -156,6 +158,7 @@
156158
<ColumnDefinition MinWidth="100" />
157159
<ColumnDefinition MinWidth="100" />
158160
<ColumnDefinition MinWidth="100" />
161+
<ColumnDefinition MinWidth="100" />
159162
</Grid.ColumnDefinitions>
160163

161164
<TextBlock Grid.Row="1"
@@ -195,6 +198,10 @@
195198
Grid.Column="5"
196199
Style="{StaticResource FieldHeader}"
197200
Text="TimePicker" />
201+
<TextBlock Grid.Row="0"
202+
Grid.Column="6"
203+
Style="{StaticResource FieldHeader}"
204+
Text="NumericUpDown" />
198205

199206
<TextBox Grid.Row="1" Grid.Column="1" />
200207
<TextBox Grid.Row="2"
@@ -251,6 +258,17 @@
251258
Grid.Column="5"
252259
Style="{StaticResource MaterialDesignOutlinedTimePicker}" />
253260

261+
<materialDesign:NumericUpDown Grid.Row="1" Grid.Column="6" />
262+
<materialDesign:NumericUpDown Grid.Row="2"
263+
Grid.Column="6"
264+
Style="{StaticResource MaterialDesignFloatingHintNumericUpDown}" />
265+
<materialDesign:NumericUpDown Grid.Row="3"
266+
Grid.Column="6"
267+
Style="{StaticResource MaterialDesignFilledNumericUpDown}" />
268+
<materialDesign:NumericUpDown Grid.Row="4"
269+
Grid.Column="6"
270+
Style="{StaticResource MaterialDesignOutlinedNumericUpDown}" />
271+
254272
</Grid>
255273
</StackPanel>
256274
</GroupBox>

src/MainDemo.Wpf/FieldsLineUp.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ private static void SetValue(Control control)
9090
case TimePicker timePicker:
9191
timePicker.SelectedTime = DateTime.Now;
9292
break;
93+
case MaterialDesignThemes.Wpf.NumericUpDown numericUpDown:
94+
numericUpDown.Value = 0;
95+
break;
9396
default:
9497
throw new NotSupportedException(control.GetType().FullName);
9598
}

src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
<ColumnDefinition MinWidth="100" />
148148
<ColumnDefinition MinWidth="100" />
149149
<ColumnDefinition MinWidth="100" />
150+
<ColumnDefinition MinWidth="100" />
150151
</Grid.ColumnDefinitions>
151152

152153
<TextBlock Grid.Row="1"
@@ -186,6 +187,10 @@
186187
Grid.Column="5"
187188
Style="{StaticResource FieldHeader}"
188189
Text="TimePicker" />
190+
<TextBlock Grid.Row="0"
191+
Grid.Column="6"
192+
Style="{StaticResource FieldHeader}"
193+
Text="NumericUpDown" />
189194

190195
<TextBox Grid.Row="1" Grid.Column="1" />
191196
<TextBox Grid.Row="2"
@@ -242,6 +247,17 @@
242247
Grid.Column="5"
243248
Style="{StaticResource MaterialDesignOutlinedTimePicker}" />
244249

250+
<materialDesign:NumericUpDown Grid.Row="1" Grid.Column="6" />
251+
<materialDesign:NumericUpDown Grid.Row="2"
252+
Grid.Column="6"
253+
Style="{StaticResource MaterialDesignFloatingHintNumericUpDown}" />
254+
<materialDesign:NumericUpDown Grid.Row="3"
255+
Grid.Column="6"
256+
Style="{StaticResource MaterialDesignFilledNumericUpDown}" />
257+
<materialDesign:NumericUpDown Grid.Row="4"
258+
Grid.Column="6"
259+
Style="{StaticResource MaterialDesignOutlinedNumericUpDown}" />
260+
245261
</Grid>
246262
</StackPanel>
247263
</GroupBox>

src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ private static void SetValue(Control control)
9090
case TimePicker timePicker:
9191
timePicker.SelectedTime = DateTime.Now;
9292
break;
93+
case NumericUpDown numericUpDown:
94+
numericUpDown.Value = 0;
95+
break;
9396
default:
9497
throw new NotSupportedException(control.GetType().FullName);
9598
}

src/MaterialDesignThemes.Wpf/DatePickerAssist.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace MaterialDesignThemes.Wpf;
22

3-
[Obsolete("This class is obsolete and will be removed in a future version. Please use the TextBoxAssist equivalents instead. For OutlinedBorderInactiveThickness, simply use BorderThickness property instead.")]
3+
[Obsolete("This class is obsolete and will be removed in a future version. Please use the TextFieldAssist equivalents instead. For OutlinedBorderInactiveThickness, simply use DatePicker.BorderThickness property instead.")]
44
public static class DatePickerAssist
55
{
66
public static readonly DependencyProperty OutlinedBorderInactiveThicknessProperty = DependencyProperty.RegisterAttached(

src/MaterialDesignThemes.Wpf/NumericUpDown.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
using System.ComponentModel;
22
using System.Globalization;
3-
using System.Windows.Automation.Peers;
43

54
namespace MaterialDesignThemes.Wpf;
65

76
[TemplatePart(Name = IncreaseButtonPartName, Type = typeof(RepeatButton))]
87
[TemplatePart(Name = DecreaseButtonPartName, Type = typeof(RepeatButton))]
9-
[TemplatePart(Name = TextFieldBoxPartName, Type = typeof(TextBox))]
8+
[TemplatePart(Name = TextBoxPartName, Type = typeof(TextBox))]
109
public class NumericUpDown : Control
1110
{
1211
public const string IncreaseButtonPartName = "PART_IncreaseButton";
1312
public const string DecreaseButtonPartName = "PART_DecreaseButton";
14-
public const string TextFieldBoxPartName = "PART_TextBoxField";
13+
public const string TextBoxPartName = "PART_TextBox";
1514

1615
private TextBox? _textBoxField;
1716
private RepeatButton? _decreaseButton;
@@ -180,7 +179,7 @@ public override void OnApplyTemplate()
180179

181180
_increaseButton = GetTemplateChild(IncreaseButtonPartName) as RepeatButton;
182181
_decreaseButton = GetTemplateChild(DecreaseButtonPartName) as RepeatButton;
183-
_textBoxField = GetTemplateChild(TextFieldBoxPartName) as TextBox;
182+
_textBoxField = GetTemplateChild(TextBoxPartName) as TextBox;
184183

185184
if (_increaseButton != null)
186185
_increaseButton.Click += IncreaseButtonOnClick;

src/MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
xmlns:local="clr-namespace:MaterialDesignThemes.Wpf"
55
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
66
xmlns:system="clr-namespace:System;assembly=mscorlib"
7-
xmlns:transitions="clr-namespace:MaterialDesignThemes.Wpf.Transitions"
8-
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
7+
xmlns:transitions="clr-namespace:MaterialDesignThemes.Wpf.Transitions">
98

109
<ResourceDictionary.MergedDictionaries>
1110
<!--
1211
we only bring in the dictionaries for controls which were "invented"
1312
as part of Material Design in XAML Toolkit. Other themes, for existing controls
1413
must be selected manually by the user, so that they override default styles.
1514
The easiest way to do this is include:
16-
15+
1716
MaterialDesignTheme.Defaults.xaml
1817
in your App.xaml
1918
-->
@@ -43,6 +42,7 @@
4342
<Style TargetType="{x:Type local:TimePicker}" BasedOn="{StaticResource MaterialDesignTimePicker}" />
4443
<Style TargetType="{x:Type local:AutoSuggestBox}" BasedOn="{StaticResource MaterialDesignAutoSuggestBox}" />
4544
<Style TargetType="{x:Type local:SplitButton}" BasedOn="{StaticResource MaterialDesignRaisedSplitButton}" />
45+
<Style TargetType="{x:Type local:NumericUpDown}" BasedOn="{StaticResource MaterialDesignNumericUpDown}" />
4646

4747
<converters:BrushToRadialGradientBrushConverter x:Key="BrushToRadialGradientBrushConverter" />
4848
<converters:DrawerOffsetConverter x:Key="DrawerOffsetConverter" />
@@ -332,7 +332,7 @@
332332
<Setter TargetName="ComponentOneTwoWrapper" Property="Opacity" Value=".56" />
333333
<Setter TargetName="ComponentThreeTextBlock" Property="Opacity" Value="1" />
334334
</Trigger>
335-
<Trigger Property="wpf:CalendarAssist.Orientation" Value="Horizontal">
335+
<Trigger Property="local:CalendarAssist.Orientation" Value="Horizontal">
336336
<Setter TargetName="ComponentOneTwoWrapper" Property="Orientation" Value="Vertical" />
337337
</Trigger>
338338
</ControlTemplate.Triggers>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Listbox.xaml" />
2424
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ListView.xaml" />
2525
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Menu.xaml" />
26+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.NumericUpDown.xaml" />
2627
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PasswordBox.xaml" />
2728
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
2829
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Listbox.xaml" />
3232
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ListView.xaml" />
3333
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Menu.xaml" />
34+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.NumericUpDown.xaml" />
3435
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PasswordBox.xaml" />
3536
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
3637
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.RadioButton.xaml" />

0 commit comments

Comments
 (0)