Skip to content

Commit 93784df

Browse files
Post SmartHint adoption cleanup (#3540)
* Replicate TextBox style in AutoSuggestBox template * Remove unused constants * Drop default HintOffset to (0,0) The HintOffset is now only used if explicitly set to a value other than the default; thus a default of (0,0) seems appropriate. * Obsolete not needed assist classes * Obsolete/delete unused converters * Add delay to AutoSuggestBox test to make it less fragile. * Ensure SUT is displayed in the middle of the window. Filling the height of the host window is problematic when a Popup needs to be shown below the control. This causes the window to increase in size and does not really imitate real life usage.
1 parent a47b242 commit 93784df

25 files changed

+410
-509
lines changed

MainDemo.Wpf/ComboBoxes.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
</smtx:XamlDisplay>
160160
<smtx:XamlDisplay UniqueKey="comboboxes_8">
161161
<ComboBox MinWidth="72"
162-
materialDesign:HintAssist.FloatingOffset="0, -24"
163162
materialDesign:HintAssist.FloatingScale="1.5"
164163
materialDesign:HintAssist.Hint="(large float hint)"
165164
ItemsSource="{Binding LongIntegerList}"

MainDemo.Wpf/Domain/SmartHintViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace MaterialDesignDemo.Domain;
55

66
internal class SmartHintViewModel : ViewModelBase
77
{
8-
public static Point DefaultFloatingOffset { get; } = new(0, -16);
8+
public static Point DefaultFloatingOffset { get; } = new(0, 0);
99
public static FontFamily DefaultFontFamily = (FontFamily)new MaterialDesignFontExtension().ProvideValue(null!);
1010

1111
private bool _floatHint = true;
@@ -46,7 +46,7 @@ internal class SmartHintViewModel : ViewModelBase
4646

4747
public IEnumerable<FloatingHintHorizontalAlignment> HorizontalAlignmentOptions { get; } = Enum.GetValues(typeof(FloatingHintHorizontalAlignment)).OfType<FloatingHintHorizontalAlignment>();
4848
public IEnumerable<double> FloatingScaleOptions { get; } = [0.25, 0.5, 0.75, 1.0];
49-
public IEnumerable<Point> FloatingOffsetOptions { get; } = [DefaultFloatingOffset, new Point(0, -25), new Point(16, -16), new Point(-16, -16), new Point(0, -50)];
49+
public IEnumerable<Point> FloatingOffsetOptions { get; } = [DefaultFloatingOffset, new Point(0, -25), new Point(0, -16), new Point(16, -16), new Point(-16, -16), new Point(0, -50)];
5050
public IEnumerable<string> ComboBoxOptions { get; } = ["Option 1", "Option 2", "Option 3"];
5151
public IEnumerable<Thickness> CustomPaddingOptions { get; } = [new Thickness(0), new Thickness(5), new Thickness(10), new Thickness(15)];
5252
public IEnumerable<double> CustomHeightOptions { get; } = [double.NaN, 50, 75, 100, 150];

MainDemo.Wpf/Pickers.xaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@
173173
HorizontalAlignment="Left"
174174
UniqueKey="pickers_unchanging_borderthickness">
175175
<DatePicker Width="140"
176-
materialDesign:DatePickerAssist.OutlinedBorderInactiveThickness="2"
177-
materialDesign:HintAssist.FloatingOffset="0,-22"
176+
BorderThickness="2"
178177
materialDesign:HintAssist.HelperText="Helper text"
179178
materialDesign:HintAssist.Hint="Pick Date"
180179
Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
@@ -184,9 +183,8 @@
184183
HorizontalAlignment="Left"
185184
UniqueKey="pickers_14_custom_borderthickness">
186185
<DatePicker Width="140"
187-
materialDesign:DatePickerAssist.OutlinedBorderActiveThickness="3"
188-
materialDesign:DatePickerAssist.OutlinedBorderInactiveThickness="3"
189-
materialDesign:HintAssist.FloatingOffset="0,-23"
186+
materialDesign:TextFieldAssist.OutlinedBorderActiveThickness="3"
187+
BorderThickness="3"
190188
materialDesign:HintAssist.HelperText="Helper text"
191189
materialDesign:HintAssist.Hint="Pick Date"
192190
Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
@@ -206,11 +204,10 @@
206204
HorizontalAlignment="Left"
207205
UniqueKey="pickers_time_custom_borderthickness">
208206
<materialDesign:TimePicker Width="140"
209-
materialDesign:HintAssist.FloatingOffset="0,-23"
210207
materialDesign:HintAssist.HelperText="Helper text"
211208
materialDesign:HintAssist.Hint="Pick Time"
212-
materialDesign:TimePickerAssist.OutlinedBorderActiveThickness="3"
213-
materialDesign:TimePickerAssist.OutlinedBorderInactiveThickness="3"
209+
materialDesign:TextFieldAssist.OutlinedBorderActiveThickness="3"
210+
BorderThickness="3"
214211
Is24Hours="True"
215212
Style="{StaticResource MaterialDesignOutlinedTimePicker}" />
216213
</smtx:XamlDisplay>

MaterialDesign3.Demo.Wpf/ComboBoxes.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@
185185
</smtx:XamlDisplay>
186186
<smtx:XamlDisplay UniqueKey="comboboxes_8">
187187
<ComboBox MinWidth="72"
188-
materialDesign:HintAssist.FloatingOffset="0, -24"
189188
materialDesign:HintAssist.FloatingScale="1.5"
190189
materialDesign:HintAssist.Hint="(large float hint)"
191190
ItemsSource="{Binding LongListToTestComboVirtualization}"

MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ await Wait.For(async () =>
7979
var bananas = await suggestionListBox.GetElement<ListBoxItem>("/ListBoxItem[0]");
8080
await bananas.MoveCursorTo();
8181
await bananas.LeftClick();
82+
83+
// Wait for the text to be updated
84+
await Task.Delay(50);
85+
8286
var suggestBoxText = await suggestBox.GetText();
8387
//Validate that the current text is the same as the selected item
8488
Assert.Equal("Bananas", suggestBoxText);

MaterialDesignThemes.UITests/XamlTestExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ public static async Task<IVisualElement> CreateWindowWithUserControl(this IApp a
115115
Title=""Test Window""
116116
Topmost=""False""
117117
WindowStartupLocation=""CenterScreen"">
118-
<local:{userControlType.Name} />
118+
<Grid>
119+
<local:{userControlType.Name} x:Name=""Container"" VerticalAlignment=""Center"" />
120+
</Grid>
119121
</Window>";
120122
IWindow window = await app.CreateWindow(windowXaml);
121-
return await window.GetElement(".Content.Content");
123+
return await window.GetElement("Container.Content");
122124
}
123125
}

MaterialDesignThemes.Wpf/Constants.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,13 @@ public static class Constants
44
{
55
public static readonly Thickness TextBoxDefaultPadding = new(0, 4, 0, 4);
66
public static readonly Thickness FloatingTextBoxDefaultPadding = new(0, 12, 0, 4);
7-
public static readonly Thickness FilledTextBoxDefaultPadding = new(16, 8, 12, 8);
7+
public static readonly Thickness FilledTextBoxDefaultPadding = new(16, 16, 12, 8);
88
public static readonly Thickness OutlinedTextBoxDefaultPadding = new(16, 16, 12, 16);
99
public static readonly Thickness DefaultTextBoxViewMargin = new(1, 0, 1, 0);
1010
public static readonly Thickness DefaultTextBoxViewMarginStretch = new(1, 18, 1, 0);
1111
public static readonly Thickness DefaultTextBoxViewMarginEmbedded = new(0);
1212
public static readonly Thickness DefaultOutlinedBorderInactiveThickness = new(1);
1313
public static readonly Thickness DefaultOutlinedBorderActiveThickness = new(2);
1414
public const double TextBoxNotEnabledOpacity = 0.56;
15-
public const double TextBoxInnerButtonSpacing = 2;
1615
public const double ComboBoxArrowSize = 8;
17-
18-
/// <summary>
19-
/// Contains temporary constants needed until all styles leveraging SmartHint adopt the new approach.
20-
/// At that point, they should all use the constants above, the values should be changed to the ones in this class,
21-
/// and the class can be deleted.
22-
///
23-
/// NOTE: XAML bindings only work on public properties/fields, so to make these fields "internal", wrapping them
24-
/// in an internal class is an acceptable compromise.
25-
/// </summary>
26-
internal static class TemporaryConstants
27-
{
28-
public static readonly Thickness FilledTextBoxDefaultPaddingNew = new(16, 16, 12, 8);
29-
}
3016
}

MaterialDesignThemes.Wpf/Converters/DoubleToThicknessConverter.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

MaterialDesignThemes.Wpf/Converters/FloatingHintOffsetCalculationConverter.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.

MaterialDesignThemes.Wpf/Converters/OutlinedDateTimePickerActiveBorderThicknessConverter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
namespace MaterialDesignThemes.Wpf.Converters;
55

6-
/* TODO: Should be obsoleted when both TimePicker and DatePicker have adopted the new SmartHint. */
7-
//[Obsolete("This class is obsolete and will be removed in a future version. Please use the more generic-named OutlinedStyleActiveBorderMarginCompensationConverter instead.")]
6+
[Obsolete("This class is obsolete and will be removed in a future version. Please use the more generic-named OutlinedStyleActiveBorderMarginCompensationConverter instead.")]
87
public class OutlinedDateTimePickerActiveBorderThicknessConverter : IMultiValueConverter
98
{
109
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)

0 commit comments

Comments
 (0)