Skip to content

Commit 6670a9c

Browse files
Adopt new SmartHint in TimePicker style (#3529)
* Fix issue with bottom of demo page being "clipped" * Add HasClearButton support in demo page for DatePicker/TimePicker * Allow TextBox to be leveraged a nested control in other styles * Minor improvement in demo app to only apply validation errors on SUTs * Only APs for custom thickness remain - may need to be generalized * Update default height tests wrt TimePicker * TimePicker adoption of SmartHint working - demo app additions missing * Demo app updated with options for BorderThickness (inactive/active) * Rename converter to better match its usage * Apply rename on obsoletion comment as well
1 parent 886d3f5 commit 6670a9c

16 files changed

+262
-627
lines changed

MainDemo.Wpf/Domain/SmartHintViewModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ internal class SmartHintViewModel : ViewModelBase
4040
private bool _newSpecHighlightingEnabled;
4141
private ScrollBarVisibility _selectedVerticalScrollBarVisibility = ScrollBarVisibility.Auto;
4242
private ScrollBarVisibility _selectedHorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
43+
private Thickness _outlineStyleBorderThickness = new(1);
44+
private Thickness _outlineStyleActiveBorderThickness = new(2);
4345

4446
public IEnumerable<FloatingHintHorizontalAlignment> HorizontalAlignmentOptions { get; } = Enum.GetValues(typeof(FloatingHintHorizontalAlignment)).OfType<FloatingHintHorizontalAlignment>();
4547
public IEnumerable<double> FloatingScaleOptions { get; } = [0.25, 0.5, 0.75, 1.0];
@@ -54,6 +56,7 @@ internal class SmartHintViewModel : ViewModelBase
5456
public IEnumerable<PrefixSuffixVisibility> PrefixSuffixVisibilityOptions { get; } = Enum.GetValues(typeof(PrefixSuffixVisibility)).OfType<PrefixSuffixVisibility>();
5557
public IEnumerable<PrefixSuffixHintBehavior> PrefixSuffixHintBehaviorOptions { get; } = Enum.GetValues(typeof(PrefixSuffixHintBehavior)).OfType<PrefixSuffixHintBehavior>();
5658
public IEnumerable<ScrollBarVisibility> ScrollBarVisibilityOptions { get; } = Enum.GetValues(typeof(ScrollBarVisibility)).OfType<ScrollBarVisibility>();
59+
public IEnumerable<Thickness> CustomOutlineStyleBorderThicknessOptions { get; } = [new Thickness(1), new Thickness(2), new Thickness(3), new Thickness(4), new Thickness(5), new Thickness(6) ];
5760

5861
public bool FloatHint
5962
{
@@ -258,4 +261,16 @@ public ScrollBarVisibility SelectedHorizontalScrollBarVisibility
258261
get => _selectedHorizontalScrollBarVisibility;
259262
set => SetProperty(ref _selectedHorizontalScrollBarVisibility, value);
260263
}
264+
265+
public Thickness OutlineStyleBorderThickness
266+
{
267+
get => _outlineStyleBorderThickness;
268+
set => SetProperty(ref _outlineStyleBorderThickness, value);
269+
}
270+
271+
public Thickness OutlineStyleActiveBorderThickness
272+
{
273+
get => _outlineStyleActiveBorderThickness;
274+
set => SetProperty(ref _outlineStyleActiveBorderThickness, value);
275+
}
261276
}

MainDemo.Wpf/SmartHint.xaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<Setter Property="materialDesign:HintAssist.FloatingScale" Value="{Binding SelectedFloatingScale}" />
2828
<Setter Property="materialDesign:HintAssist.HelperText" Value="{Binding HelperText}" />
2929
<Setter Property="materialDesign:HintAssist.Hint" Value="{Binding HintText}" />
30+
<Setter Property="materialDesign:TextFieldAssist.OutlinedBorderActiveThickness" Value="{Binding OutlineStyleActiveBorderThickness}" />
3031
</Style>
3132
<Style x:Key="StyleNameIndicator"
3233
TargetType="{x:Type TextBlock}"
@@ -242,6 +243,14 @@
242243
VerticalAlignment="Center"
243244
ItemsSource="{Binding PrefixSuffixHintBehaviorOptions}"
244245
SelectedItem="{Binding SelectedPrefixHintBehavior}"/>
246+
<TextBlock Margin="40,0,0,0"
247+
VerticalAlignment="Center"
248+
Text="OutlineStyle-BorderThickness:" />
249+
<ComboBox Width="62"
250+
Margin="5,0,0,0"
251+
VerticalAlignment="Center"
252+
ItemsSource="{Binding CustomOutlineStyleBorderThicknessOptions}"
253+
SelectedItem="{Binding OutlineStyleBorderThickness}" />
245254
</StackPanel>
246255
<StackPanel Margin="10" Orientation="Horizontal">
247256
<TextBox Width="50"
@@ -265,6 +274,14 @@
265274
VerticalAlignment="Center"
266275
ItemsSource="{Binding PrefixSuffixHintBehaviorOptions}"
267276
SelectedItem="{Binding SelectedSuffixHintBehavior}"/>
277+
<TextBlock Margin="40,0,0,0"
278+
VerticalAlignment="Center"
279+
Text="OutlineStyle-ActiveBorderThickness:" />
280+
<ComboBox Width="62"
281+
Margin="5,0,0,0"
282+
VerticalAlignment="Center"
283+
ItemsSource="{Binding CustomOutlineStyleBorderThicknessOptions}"
284+
SelectedItem="{Binding OutlineStyleActiveBorderThickness}" />
268285
</StackPanel>
269286
</StackPanel>
270287
</GroupBox>
@@ -328,7 +345,6 @@
328345
</StackPanel>
329346

330347
<ScrollViewer Grid.Row="3"
331-
Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ScrollViewer}}, Path=ViewportHeight, Converter={StaticResource SubtractConverter}, ConverterParameter=350}"
332348
Margin="0,20,0,0"
333349
VerticalAlignment="Top"
334350
materialDesign:ScrollViewerAssist.BubbleVerticalScroll="False"
@@ -494,6 +510,7 @@
494510
<Grid.Resources>
495511
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignOutlinedTextBox}">
496512
<Setter Property="AcceptsReturn" Value="{Binding TextBoxAcceptsReturn}" />
513+
<Setter Property="BorderThickness" Value="{Binding OutlineStyleBorderThickness}" />
497514
<Setter Property="FontSize" Value="{Binding SelectedFontSize, Converter={StaticResource FontSizeConverter}}" />
498515
<Setter Property="Height" Value="{Binding SelectedCustomHeight}" />
499516
<Setter Property="Padding">
@@ -747,6 +764,7 @@
747764
<Grid>
748765
<Grid.Resources>
749766
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MaterialDesignOutlinedPasswordBox}">
767+
<Setter Property="BorderThickness" Value="{Binding OutlineStyleBorderThickness}" />
750768
<Setter Property="FontSize" Value="{Binding SelectedFontSize, Converter={StaticResource FontSizeConverter}}" />
751769
<Setter Property="Height" Value="{Binding SelectedCustomHeight}" />
752770
<Setter Property="Padding">
@@ -938,6 +956,7 @@
938956
<Grid>
939957
<Grid.Resources>
940958
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MaterialDesignOutlinedRevealPasswordBox}">
959+
<Setter Property="BorderThickness" Value="{Binding OutlineStyleBorderThickness}" />
941960
<Setter Property="FontSize" Value="{Binding SelectedFontSize, Converter={StaticResource FontSizeConverter}}" />
942961
<Setter Property="Height" Value="{Binding SelectedCustomHeight}" />
943962
<Setter Property="Padding">
@@ -1127,6 +1146,7 @@
11271146
<Grid>
11281147
<Grid.Resources>
11291148
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MaterialDesignOutlinedComboBox}">
1149+
<Setter Property="BorderThickness" Value="{Binding OutlineStyleBorderThickness}" />
11301150
<Setter Property="FontSize" Value="{Binding SelectedFontSize, Converter={StaticResource FontSizeConverter}}" />
11311151
<Setter Property="Height" Value="{Binding SelectedCustomHeight}" />
11321152
<Setter Property="IsEditable" Value="{Binding ElementName=ComboBoxesEditableCheckBox, Path=IsChecked}" />
@@ -1207,6 +1227,7 @@
12071227
<Setter Property="VerticalContentAlignment" Value="{Binding SelectedVerticalAlignment}" />
12081228
<Setter Property="materialDesign:HintAssist.FontFamily" Value="{Binding SelectedFontFamily}" />
12091229
<Setter Property="materialDesign:HintAssist.IsFloating" Value="{Binding FloatHint}" />
1230+
<Setter Property="materialDesign:TextFieldAssist.HasClearButton" Value="{Binding ShowClearButton}" />
12101231
<Setter Property="materialDesign:TextFieldAssist.HasLeadingIcon" Value="{Binding ShowLeadingIcon}" />
12111232
<Setter Property="materialDesign:TextFieldAssist.HasTrailingIcon" Value="{Binding ShowTrailingIcon}" />
12121233
<Setter Property="materialDesign:TextFieldAssist.LeadingIcon" Value="{StaticResource LeadingIcon}" />
@@ -1264,6 +1285,7 @@
12641285
<Setter Property="VerticalContentAlignment" Value="{Binding SelectedVerticalAlignment}" />
12651286
<Setter Property="materialDesign:HintAssist.FontFamily" Value="{Binding SelectedFontFamily}" />
12661287
<Setter Property="materialDesign:HintAssist.IsFloating" Value="{Binding FloatHint}" />
1288+
<Setter Property="materialDesign:TextFieldAssist.HasClearButton" Value="{Binding ShowClearButton}" />
12671289
<Setter Property="materialDesign:TextFieldAssist.HasLeadingIcon" Value="{Binding ShowLeadingIcon}" />
12681290
<Setter Property="materialDesign:TextFieldAssist.HasTrailingIcon" Value="{Binding ShowTrailingIcon}" />
12691291
<Setter Property="materialDesign:TextFieldAssist.LeadingIcon" Value="{StaticResource LeadingIcon}" />
@@ -1306,6 +1328,7 @@
13061328
<Grid>
13071329
<Grid.Resources>
13081330
<Style TargetType="{x:Type DatePicker}" BasedOn="{StaticResource MaterialDesignOutlinedDatePicker}">
1331+
<Setter Property="BorderThickness" Value="{Binding OutlineStyleBorderThickness}" />
13091332
<Setter Property="FontSize" Value="{Binding SelectedFontSize, Converter={StaticResource FontSizeConverter}}" />
13101333
<Setter Property="Height" Value="{Binding SelectedCustomHeight}" />
13111334
<Setter Property="Padding">
@@ -1321,6 +1344,7 @@
13211344
<Setter Property="VerticalContentAlignment" Value="{Binding SelectedVerticalAlignment}" />
13221345
<Setter Property="materialDesign:HintAssist.FontFamily" Value="{Binding SelectedFontFamily}" />
13231346
<Setter Property="materialDesign:HintAssist.IsFloating" Value="{Binding FloatHint}" />
1347+
<Setter Property="materialDesign:TextFieldAssist.HasClearButton" Value="{Binding ShowClearButton}" />
13241348
<Setter Property="materialDesign:TextFieldAssist.HasLeadingIcon" Value="{Binding ShowLeadingIcon}" />
13251349
<Setter Property="materialDesign:TextFieldAssist.HasTrailingIcon" Value="{Binding ShowTrailingIcon}" />
13261350
<Setter Property="materialDesign:TextFieldAssist.LeadingIcon" Value="{StaticResource LeadingIcon}" />
@@ -1383,6 +1407,7 @@
13831407
<Setter Property="VerticalContentAlignment" Value="{Binding SelectedVerticalAlignment}" />
13841408
<Setter Property="materialDesign:HintAssist.FontFamily" Value="{Binding SelectedFontFamily}" />
13851409
<Setter Property="materialDesign:HintAssist.IsFloating" Value="{Binding FloatHint}" />
1410+
<Setter Property="materialDesign:TextFieldAssist.HasClearButton" Value="{Binding ShowClearButton}" />
13861411
<Setter Property="materialDesign:TextFieldAssist.HasLeadingIcon" Value="{Binding ShowLeadingIcon}" />
13871412
<Setter Property="materialDesign:TextFieldAssist.HasTrailingIcon" Value="{Binding ShowTrailingIcon}" />
13881413
<Setter Property="materialDesign:TextFieldAssist.LeadingIcon" Value="{StaticResource LeadingIcon}" />
@@ -1440,6 +1465,7 @@
14401465
<Setter Property="VerticalContentAlignment" Value="{Binding SelectedVerticalAlignment}" />
14411466
<Setter Property="materialDesign:HintAssist.FontFamily" Value="{Binding SelectedFontFamily}" />
14421467
<Setter Property="materialDesign:HintAssist.IsFloating" Value="{Binding FloatHint}" />
1468+
<Setter Property="materialDesign:TextFieldAssist.HasClearButton" Value="{Binding ShowClearButton}" />
14431469
<Setter Property="materialDesign:TextFieldAssist.HasLeadingIcon" Value="{Binding ShowLeadingIcon}" />
14441470
<Setter Property="materialDesign:TextFieldAssist.HasTrailingIcon" Value="{Binding ShowTrailingIcon}" />
14451471
<Setter Property="materialDesign:TextFieldAssist.LeadingIcon" Value="{StaticResource LeadingIcon}" />
@@ -1482,6 +1508,7 @@
14821508
<Grid>
14831509
<Grid.Resources>
14841510
<Style TargetType="{x:Type materialDesign:TimePicker}" BasedOn="{StaticResource MaterialDesignOutlinedTimePicker}">
1511+
<Setter Property="BorderThickness" Value="{Binding OutlineStyleBorderThickness}" />
14851512
<Setter Property="FontSize" Value="{Binding SelectedFontSize, Converter={StaticResource FontSizeConverter}}" />
14861513
<Setter Property="Height" Value="{Binding SelectedCustomHeight}" />
14871514
<Setter Property="Padding">
@@ -1497,6 +1524,7 @@
14971524
<Setter Property="VerticalContentAlignment" Value="{Binding SelectedVerticalAlignment}" />
14981525
<Setter Property="materialDesign:HintAssist.FontFamily" Value="{Binding SelectedFontFamily}" />
14991526
<Setter Property="materialDesign:HintAssist.IsFloating" Value="{Binding FloatHint}" />
1527+
<Setter Property="materialDesign:TextFieldAssist.HasClearButton" Value="{Binding ShowClearButton}" />
15001528
<Setter Property="materialDesign:TextFieldAssist.HasLeadingIcon" Value="{Binding ShowLeadingIcon}" />
15011529
<Setter Property="materialDesign:TextFieldAssist.HasTrailingIcon" Value="{Binding ShowTrailingIcon}" />
15021530
<Setter Property="materialDesign:TextFieldAssist.LeadingIcon" Value="{StaticResource LeadingIcon}" />

MainDemo.Wpf/SmartHint.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ private void HasErrors_OnToggled(object sender, RoutedEventArgs e)
2727
{
2828
CheckBox c = (CheckBox) sender;
2929

30-
foreach (FrameworkElement element in FindVisualChildren<FrameworkElement>(ControlsPanel))
30+
foreach (InputElementContentControl container in FindVisualChildren<InputElementContentControl>(ControlsPanel))
3131
{
32+
FrameworkElement element = (FrameworkElement) container.Content;
33+
3234
var binding = GetBinding(element);
3335
if (binding is null)
3436
continue;

MaterialDesignThemes.UITests/WPF/TextFieldDefaultHeightTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ public async Task SameHeightWithDefaultStyle()
1717
<PasswordBox />
1818
<ComboBox IsEditable=""True"" />
1919
<DatePicker />
20-
<materialDesign:TimePicker />
2120
</StackPanel>");
2221

2322
var height = await GetHeight(stackPanel, "PasswordBox");
2423
Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
2524
Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision);
26-
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
2725

2826
recorder.Success();
2927
}
@@ -37,10 +35,12 @@ public async Task SameHeightWithDefaultStyle_PostSmartHintRefactor()
3735
var stackPanel = await LoadXaml<StackPanel>(@"
3836
<StackPanel>
3937
<TextBox />
38+
<materialDesign:TimePicker />
4039
</StackPanel>");
4140

4241
var height = await GetHeight(stackPanel, "TextBox");
4342
//Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
43+
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
4444

4545
recorder.Success();
4646
}
@@ -56,14 +56,12 @@ public async Task SameHeightWithFloatingHintStyle()
5656
<PasswordBox Style=""{StaticResource MaterialDesignFloatingHintPasswordBox}"" materialDesign:HintAssist.Hint=""Hint"" />
5757
<ComboBox IsEditable=""True"" Style=""{StaticResource MaterialDesignFloatingHintComboBox}"" materialDesign:HintAssist.Hint=""Hint"" />
5858
<DatePicker Style=""{StaticResource MaterialDesignFloatingHintDatePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
59-
<materialDesign:TimePicker Style=""{StaticResource MaterialDesignFloatingHintTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
6059
</StackPanel>");
6160

6261
var height = await GetHeight(stackPanel, "PasswordBox");
6362
Assert.True(height > 0);
6463
Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
6564
Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision);
66-
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
6765

6866
recorder.Success();
6967
}
@@ -77,11 +75,13 @@ public async Task SameHeightWithFloatingHintStyle_PostSmartHintRefactor()
7775
var stackPanel = await LoadXaml<StackPanel>(@"
7876
<StackPanel>
7977
<TextBox Style=""{StaticResource MaterialDesignFloatingHintTextBox}"" materialDesign:HintAssist.Hint=""Hint"" />
78+
<materialDesign:TimePicker Style=""{StaticResource MaterialDesignFloatingHintTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
8079
</StackPanel>");
8180

8281
var height = await GetHeight(stackPanel, "TextBox");
8382
Assert.True(height > 0);
8483
//Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
84+
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
8585

8686
recorder.Success();
8787
}
@@ -97,14 +97,12 @@ public async Task SameHeightWithFilledStyle()
9797
<PasswordBox Style=""{StaticResource MaterialDesignFilledPasswordBox}"" materialDesign:HintAssist.Hint=""Hint"" />
9898
<ComboBox IsEditable=""True"" Style=""{StaticResource MaterialDesignFilledComboBox}"" materialDesign:HintAssist.Hint=""Hint"" />
9999
<DatePicker Style=""{StaticResource MaterialDesignFilledDatePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
100-
<materialDesign:TimePicker Style=""{StaticResource MaterialDesignFilledTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
101100
</StackPanel>");
102101

103102
var height = await GetHeight(stackPanel, "PasswordBox");
104103
Assert.True(height > 0);
105104
Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
106105
Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision);
107-
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
108106

109107
recorder.Success();
110108
}
@@ -118,11 +116,13 @@ public async Task SameHeightWithFilledStyle_PostSmartHintRefactor()
118116
var stackPanel = await LoadXaml<StackPanel>(@"
119117
<StackPanel>
120118
<TextBox Style=""{StaticResource MaterialDesignFilledTextBox}"" materialDesign:HintAssist.Hint=""Hint"" />
119+
<materialDesign:TimePicker Style=""{StaticResource MaterialDesignFilledTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
121120
</StackPanel>");
122121

123122
var height = await GetHeight(stackPanel, "TextBox");
124123
Assert.True(height > 0);
125124
//Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
125+
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
126126

127127
recorder.Success();
128128
}
@@ -138,14 +138,12 @@ public async Task SameHeightWithOutlinedStyle()
138138
<PasswordBox Style=""{StaticResource MaterialDesignOutlinedPasswordBox}"" materialDesign:HintAssist.Hint=""Hint"" />
139139
<ComboBox IsEditable=""True"" Style=""{StaticResource MaterialDesignOutlinedComboBox}"" />
140140
<DatePicker Style=""{StaticResource MaterialDesignOutlinedDatePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
141-
<materialDesign:TimePicker Style=""{StaticResource MaterialDesignOutlinedTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
142141
</StackPanel>");
143142

144143
var height = await GetHeight(stackPanel, "PasswordBox");
145144
Assert.True(height > 0);
146145
Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
147146
Assert.Equal(height, await GetHeight(stackPanel, "DatePicker"), Precision);
148-
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
149147

150148
recorder.Success();
151149
}
@@ -159,11 +157,13 @@ public async Task SameHeightWithOutlinedStyle_PostSmartHintRefactor()
159157
var stackPanel = await LoadXaml<StackPanel>(@"
160158
<StackPanel>
161159
<TextBox Style=""{StaticResource MaterialDesignOutlinedTextBox}"" materialDesign:HintAssist.Hint=""Hint"" />
160+
<materialDesign:TimePicker Style=""{StaticResource MaterialDesignOutlinedTimePicker}"" materialDesign:HintAssist.Hint=""Hint"" />
162161
</StackPanel>");
163162

164163
var height = await GetHeight(stackPanel, "TextBox");
165164
Assert.True(height > 0);
166165
//Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision);
166+
Assert.Equal(height, await GetHeight(stackPanel, "TimePicker"), Precision);
167167

168168
recorder.Success();
169169
}

0 commit comments

Comments
 (0)