From e8be90343eb176fdb72d6b1be66097921baa1691 Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Tue, 27 Feb 2024 10:33:18 +0100 Subject: [PATCH 1/7] Fix return- and parameter types in VerticalAlignmentConverter --- MaterialDesignThemes.Wpf/SmartHint.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MaterialDesignThemes.Wpf/SmartHint.cs b/MaterialDesignThemes.Wpf/SmartHint.cs index 7645cf048d..68cd33cbf8 100644 --- a/MaterialDesignThemes.Wpf/SmartHint.cs +++ b/MaterialDesignThemes.Wpf/SmartHint.cs @@ -241,9 +241,9 @@ private void RefreshState(bool useTransitions) public class VerticalAlignmentConverter : IValueConverter { public VerticalAlignment StretchReplacement { get; set; } = VerticalAlignment.Top; - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is VerticalAlignment.Stretch ? StretchReplacement : value; - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException(); } From 6a3b3eefd7db122df6634a26bc9f9ace0104a73d Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Tue, 27 Feb 2024 10:36:25 +0100 Subject: [PATCH 2/7] Move VerticalAlignmentConverter into its own file under the Converters namespace --- .../Converters/VerticalAlignmentConverter.cs | 15 +++++++++++++++ MaterialDesignThemes.Wpf/SmartHint.cs | 12 ------------ .../Themes/MaterialDesignTheme.ComboBox.xaml | 2 +- .../Themes/MaterialDesignTheme.DatePicker.xaml | 2 +- .../Themes/MaterialDesignTheme.PasswordBox.xaml | 2 +- .../Themes/MaterialDesignTheme.SmartHint.xaml | 2 +- .../Themes/MaterialDesignTheme.TextBox.xaml | 2 +- .../Themes/MaterialDesignTheme.TimePicker.xaml | 2 +- 8 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 MaterialDesignThemes.Wpf/Converters/VerticalAlignmentConverter.cs diff --git a/MaterialDesignThemes.Wpf/Converters/VerticalAlignmentConverter.cs b/MaterialDesignThemes.Wpf/Converters/VerticalAlignmentConverter.cs new file mode 100644 index 0000000000..ce358258fc --- /dev/null +++ b/MaterialDesignThemes.Wpf/Converters/VerticalAlignmentConverter.cs @@ -0,0 +1,15 @@ +using System.Globalization; +using System.Windows.Data; + +namespace MaterialDesignThemes.Wpf.Converters +{ + public class VerticalAlignmentConverter : IValueConverter + { + public VerticalAlignment StretchReplacement { get; set; } = VerticalAlignment.Top; + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + => value is VerticalAlignment.Stretch ? StretchReplacement : value; + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + => throw new NotImplementedException(); + } +} diff --git a/MaterialDesignThemes.Wpf/SmartHint.cs b/MaterialDesignThemes.Wpf/SmartHint.cs index 68cd33cbf8..de82f3c916 100644 --- a/MaterialDesignThemes.Wpf/SmartHint.cs +++ b/MaterialDesignThemes.Wpf/SmartHint.cs @@ -1,6 +1,4 @@ using System.ComponentModel; -using System.Globalization; -using System.Windows.Data; using MaterialDesignThemes.Wpf.Converters; namespace MaterialDesignThemes.Wpf; @@ -237,13 +235,3 @@ private void RefreshState(bool useTransitions) } } } - -public class VerticalAlignmentConverter : IValueConverter -{ - public VerticalAlignment StretchReplacement { get; set; } = VerticalAlignment.Top; - public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - => value is VerticalAlignment.Stretch ? StretchReplacement : value; - - public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - => throw new NotImplementedException(); -} diff --git a/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml index 42de0081e1..e4ae3d66d6 100644 --- a/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml +++ b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml @@ -35,7 +35,7 @@ - + 4 diff --git a/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml index 4de202b3e5..2aa41799f2 100644 --- a/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml +++ b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml @@ -28,7 +28,7 @@ AdditionalOffsetTop="12" CloneEdges="Top,Right,Bottom" FixedLeft="0" /> - + @@ -164,7 +158,15 @@ Header="Control Settings" Style="{StaticResource MaterialDesignCardGroupBox}"> + + @@ -281,13 +284,20 @@ + VerticalAlignment="Top" + IsEnabled="{Binding ControlsEnabled}"> - + + + + @@ -323,22 +334,23 @@ MaterialDesignFloatingHintTextBox - + - - + + - - + + - - + + - + @@ -374,22 +387,23 @@ MaterialDesignFilledTextBox - + - - + + - - + + - - + + - + @@ -425,18 +440,18 @@ MaterialDesignOutlinedTextBox - + - - + + - - + + - - + + - + @@ -474,6 +489,7 @@ + @@ -486,18 +502,18 @@ MaterialDesignRichTextBox - + - - + + - - + + - - + + - + @@ -531,6 +547,7 @@ + @@ -542,18 +559,18 @@ MaterialDesignFloatingHintPasswordBox - + - - + + - - + + - - + + - + @@ -582,6 +599,7 @@ + @@ -593,18 +611,18 @@ MaterialDesignFilledPasswordBox - + - - + + - - + + - - + + - + @@ -633,6 +651,7 @@ + @@ -644,18 +663,18 @@ MaterialDesignOutlinedPasswordBox - + - - + + - - + + - - + + - + @@ -694,6 +713,7 @@ + @@ -705,18 +725,18 @@ MaterialDesignFloatingHintRevealPasswordBox - + - - + + - - + + - - + + - + @@ -746,6 +766,7 @@ + @@ -757,18 +778,18 @@ MaterialDesignFilledRevealPasswordBox - + - - + + - - + + - - + + - + @@ -798,6 +819,7 @@ + @@ -809,18 +831,18 @@ MaterialDesignOutlinedRevealPasswordBox - + - - + + - - + + - - + + - + @@ -859,6 +881,7 @@ + @@ -870,18 +893,18 @@ MaterialDesignFloatingHintComboBox - + - - + + - - + + - - + + - + @@ -912,6 +935,7 @@ + @@ -923,18 +947,18 @@ MaterialDesignFilledComboBox - + - - + + - - + + - - + + - + @@ -965,6 +989,7 @@ + @@ -976,18 +1001,18 @@ MaterialDesignOutlinedComboBox - + - - + + - - + + - - + + - + @@ -1020,6 +1045,7 @@ + @@ -1031,18 +1057,18 @@ MaterialDesignFloatingHintDatePicker - + - - + + - - + + - - + + - + @@ -1070,6 +1096,7 @@ + @@ -1081,18 +1108,18 @@ MaterialDesignFilledDatePicker - + - - + + - - + + - - + + - + @@ -1120,6 +1147,7 @@ + @@ -1131,18 +1159,18 @@ MaterialDesignOutlinedDatePicker - + - - + + - - + + - - + + - + @@ -1175,6 +1203,7 @@ + @@ -1186,18 +1215,18 @@ MaterialDesignFloatingHintTimePicker - + - - + + - - + + - - + + - + @@ -1225,6 +1254,7 @@ + @@ -1236,18 +1266,18 @@ MaterialDesignFilledTimePicker - + - - + + - - + + - - + + - + @@ -1275,6 +1305,7 @@ + @@ -1286,18 +1317,18 @@ MaterialDesignOutlinedTimePicker - + - - + + - - + + - - + + - + From 4074d10c1ac1313f43fe1613ac5a6b145be96f2d Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Tue, 27 Feb 2024 14:51:52 +0100 Subject: [PATCH 4/7] Reset default demo app page back to "Home" --- MainDemo.Wpf/Properties/launchSettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MainDemo.Wpf/Properties/launchSettings.json b/MainDemo.Wpf/Properties/launchSettings.json index aa143eaeea..3b8cbc0041 100644 --- a/MainDemo.Wpf/Properties/launchSettings.json +++ b/MainDemo.Wpf/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Demo App": { "commandName": "Project", - "commandLineArgs": "-p 3DTest -t Inherit -f LeftToRight" + "commandLineArgs": "-p Home -t Inherit -f LeftToRight" } } } From 3b61edd76a436833e1019464e8939b70ee0b84a4 Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Mon, 4 Mar 2024 20:50:25 +0100 Subject: [PATCH 5/7] Add character counter toggle to demo app (cherry picked from commit 555d6f9979cb32e004ceb02a716d8fe11ec3d601) --- MainDemo.Wpf/Domain/SmartHintViewModel.cs | 17 +++++++++++++++++ MainDemo.Wpf/SmartHint.xaml | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/MainDemo.Wpf/Domain/SmartHintViewModel.cs b/MainDemo.Wpf/Domain/SmartHintViewModel.cs index 4373175818..de86d850a8 100644 --- a/MainDemo.Wpf/Domain/SmartHintViewModel.cs +++ b/MainDemo.Wpf/Domain/SmartHintViewModel.cs @@ -30,6 +30,7 @@ internal class SmartHintViewModel : ViewModelBase private bool _controlsEnabled = true; private bool _rippleOnFocus = false; private bool _textBoxAcceptsReturn = false; + private int _maxLength; public IEnumerable HorizontalAlignmentOptions { get; } = Enum.GetValues(typeof(FloatingHintHorizontalAlignment)).OfType(); public IEnumerable FloatingScaleOptions { get; } = new[] {0.25, 0.5, 0.75, 1.0}; @@ -173,4 +174,20 @@ public bool TextBoxAcceptsReturn get => _textBoxAcceptsReturn; set => SetProperty(ref _textBoxAcceptsReturn, value); } + + public bool ShowCharacterCounter + { + get => MaxLength > 0; + set => MaxLength = value == true ? 50 : 0; + } + + public int MaxLength + { + get => _maxLength; + set + { + SetProperty(ref _maxLength, value); + OnPropertyChanged(nameof(ShowCharacterCounter)); + } + } } diff --git a/MainDemo.Wpf/SmartHint.xaml b/MainDemo.Wpf/SmartHint.xaml index e7e27197c1..981158061a 100644 --- a/MainDemo.Wpf/SmartHint.xaml +++ b/MainDemo.Wpf/SmartHint.xaml @@ -149,6 +149,10 @@ IsEnabled="{Binding ElementName=CheckBoxTrailingIcon, Path=IsChecked}" ItemsSource="{Binding IconSizeOptions}" SelectedItem="{Binding SelectedTrailingIconSize, Mode=TwoWay}" /> + @@ -323,6 +327,7 @@ + @@ -376,6 +381,7 @@ + @@ -429,6 +435,7 @@ + @@ -490,7 +497,6 @@ - @@ -548,6 +554,8 @@ + + @@ -600,6 +608,8 @@ + + @@ -652,6 +662,8 @@ + + @@ -714,6 +726,8 @@ + + @@ -767,6 +781,8 @@ + + @@ -820,6 +836,8 @@ + + From dec7d77d10a2d96189a112ebd87d0925c23cabc1 Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Tue, 5 Mar 2024 21:44:46 +0100 Subject: [PATCH 6/7] Ensure container cannot grab keyboard focus --- MainDemo.Wpf/InputElementContentControl.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MainDemo.Wpf/InputElementContentControl.cs b/MainDemo.Wpf/InputElementContentControl.cs index 6ec979ecc5..6e54f9a1dc 100644 --- a/MainDemo.Wpf/InputElementContentControl.cs +++ b/MainDemo.Wpf/InputElementContentControl.cs @@ -5,4 +5,5 @@ /// internal class InputElementContentControl : ContentControl { + public InputElementContentControl() => IsTabStop = false; } From 9407c38b7388d0d1678e27723804c00a57d45132 Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Wed, 6 Mar 2024 13:28:33 +0100 Subject: [PATCH 7/7] Remove binding errors on SmartHint demo page --- MainDemo.Wpf/SmartHint.xaml | 39 +++++++++++++++++----------------- MainDemo.Wpf/SmartHint.xaml.cs | 12 +++++++++++ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/MainDemo.Wpf/SmartHint.xaml b/MainDemo.Wpf/SmartHint.xaml index 981158061a..ad51ffae28 100644 --- a/MainDemo.Wpf/SmartHint.xaml +++ b/MainDemo.Wpf/SmartHint.xaml @@ -54,6 +54,7 @@ + @@ -302,7 +303,7 @@