From aca6b249f78d6aecc61e63eb3671a092d6cb70fb Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Wed, 8 Jan 2025 01:38:12 +0100 Subject: [PATCH 1/7] Add opt-in AP to control margins in menu variants (#3760) * Add new AP to control "ItemsPresenter margin" in the menu variants Defaults to the original value of "0, 16" and as such is an opt-in feature. * Align demo apps and showcase usage of new AP --- src/MainDemo.Wpf/MenusAndToolBars.xaml | 70 +++++- src/MaterialDesign3.Demo.Wpf/App.xaml | 15 ++ .../MenusAndToolBars.xaml | 225 ++++++++++++++++-- src/MaterialDesignThemes.Wpf/MenuAssist.cs | 13 +- .../Themes/MaterialDesignTheme.Menu.xaml | 6 +- 5 files changed, 306 insertions(+), 23 deletions(-) diff --git a/src/MainDemo.Wpf/MenusAndToolBars.xaml b/src/MainDemo.Wpf/MenusAndToolBars.xaml index ae61fd818e..acd222f9e0 100644 --- a/src/MainDemo.Wpf/MenusAndToolBars.xaml +++ b/src/MainDemo.Wpf/MenusAndToolBars.xaml @@ -1,4 +1,4 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -345,6 +398,21 @@ + + + + + + + + + + + + + + + diff --git a/src/MaterialDesign3.Demo.Wpf/App.xaml b/src/MaterialDesign3.Demo.Wpf/App.xaml index eb02cdc8a1..b1731454db 100644 --- a/src/MaterialDesign3.Demo.Wpf/App.xaml +++ b/src/MaterialDesign3.Demo.Wpf/App.xaml @@ -124,6 +124,21 @@ + + + + + + + diff --git a/src/MaterialDesign3.Demo.Wpf/MenusAndToolBars.xaml b/src/MaterialDesign3.Demo.Wpf/MenusAndToolBars.xaml index 797348de8b..f1bb219680 100644 --- a/src/MaterialDesign3.Demo.Wpf/MenusAndToolBars.xaml +++ b/src/MaterialDesign3.Demo.Wpf/MenusAndToolBars.xaml @@ -8,7 +8,10 @@ d:DesignHeight="300" d:DesignWidth="300" mc:Ignorable="d"> - + + + + @@ -57,6 +60,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The menu height matches with the parent panel height. Use the splitter to see the adaptive menu in action. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -178,28 +346,51 @@ - + + + + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MaterialDesignThemes.Wpf/MenuAssist.cs b/src/MaterialDesignThemes.Wpf/MenuAssist.cs index d64952c876..1f6a5e7930 100644 --- a/src/MaterialDesignThemes.Wpf/MenuAssist.cs +++ b/src/MaterialDesignThemes.Wpf/MenuAssist.cs @@ -1,5 +1,3 @@ -using System.Windows.Media; - namespace MaterialDesignThemes.Wpf; public static class MenuAssist @@ -14,4 +12,15 @@ public static readonly DependencyProperty TopLevelMenuItemHeightProperty public static double GetTopLevelMenuItemHeight(DependencyObject element) => (double)element.GetValue(TopLevelMenuItemHeightProperty); public static void SetTopLevelMenuItemHeight(DependencyObject element, double value) => element.SetValue(TopLevelMenuItemHeightProperty, value); #endregion + + public static readonly DependencyProperty MenuItemsPresenterMarginProperty = + DependencyProperty.RegisterAttached( + "MenuItemsPresenterMargin", + typeof(Thickness), + typeof(MenuAssist), + new FrameworkPropertyMetadata(new Thickness(0, 16, 0, 16), FrameworkPropertyMetadataOptions.Inherits)); + public static Thickness GetMenuItemsPresenterMargin(DependencyObject obj) + => (Thickness)obj.GetValue(MenuItemsPresenterMarginProperty); + public static void SetMenuItemsPresenterMargin(DependencyObject obj, Thickness value) + => obj.SetValue(MenuItemsPresenterMarginProperty, value); } diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Menu.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Menu.xaml index 21b71ad276..ec889970af 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Menu.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Menu.xaml @@ -1,4 +1,4 @@ - @@ -186,7 +186,7 @@ Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" wpf:ScrollViewerAssist.IgnorePadding="{Binding Path=(wpf:ScrollViewerAssist.IgnorePadding), RelativeSource={RelativeSource TemplatedParent}}" wpf:ScrollViewerAssist.PaddingMode="{Binding Path=(wpf:ScrollViewerAssist.PaddingMode), RelativeSource={RelativeSource TemplatedParent}}"> - + - + Date: Thu, 9 Jan 2025 19:52:36 +0100 Subject: [PATCH 2/7] added AutoSuggestBox to MD2&3 FieldsLineUp demo (#3763) * added AutoSuggestBox to MD2 FieldsLineUp demo * added AutoSuggestBox to MD3 FieldsLineUp demo --- src/MainDemo.Wpf/FieldsLineUp.xaml | 16 ++++++++++++++++ src/MainDemo.Wpf/FieldsLineUp.xaml.cs | 3 +++ src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml | 16 ++++++++++++++++ .../FieldsLineUp.xaml.cs | 3 +++ 4 files changed, 38 insertions(+) diff --git a/src/MainDemo.Wpf/FieldsLineUp.xaml b/src/MainDemo.Wpf/FieldsLineUp.xaml index d8d82fb829..cc16ac9768 100644 --- a/src/MainDemo.Wpf/FieldsLineUp.xaml +++ b/src/MainDemo.Wpf/FieldsLineUp.xaml @@ -159,6 +159,7 @@ + + + + + + + diff --git a/src/MainDemo.Wpf/FieldsLineUp.xaml.cs b/src/MainDemo.Wpf/FieldsLineUp.xaml.cs index 97ea7a074b..5ad4bcacac 100644 --- a/src/MainDemo.Wpf/FieldsLineUp.xaml.cs +++ b/src/MainDemo.Wpf/FieldsLineUp.xaml.cs @@ -73,6 +73,9 @@ private static void SetValue(Control control) { switch (control) { + case MaterialDesignThemes.Wpf.AutoSuggestBox autoSuggestBox: + autoSuggestBox.Text = nameof(MaterialDesignThemes.Wpf.AutoSuggestBox.Text); + break; case TextBox textBox: textBox.Text = nameof(TextBox.Text); break; diff --git a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml index c9c36351c5..ed90c7fa03 100644 --- a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml +++ b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml @@ -148,6 +148,7 @@ + + + + + + + diff --git a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs index 052b836e39..84dfec9f58 100644 --- a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs +++ b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs @@ -73,6 +73,9 @@ private static void SetValue(Control control) { switch (control) { + case MaterialDesignThemes.Wpf.AutoSuggestBox autoSuggestBox: + autoSuggestBox.Text = nameof(MaterialDesignThemes.Wpf.AutoSuggestBox.Text); + break; case TextBox textBox: textBox.Text = nameof(TextBox.Text); break; From 9e71c5c27e06a4f9b6d523b4fe7b1bb9b3cddfe1 Mon Sep 17 00:00:00 2001 From: Corvin <43533385+corvinsz@users.noreply.github.com> Date: Fri, 10 Jan 2025 06:08:05 +0100 Subject: [PATCH 3/7] Added Attached Property "TextFieldAssist.ClearButtonSize" (#3754) * Cleanup of launchSettings and Cards Page in Demo * Revert "Cleanup of launchSettings and Cards Page in Demo" This reverts commit ede38d4cb72c73549d6675009ec07a36fba0fe7d. * added AP TextFieldAssist.ClearButtonSize to control the size of the ClearButton * apply TextFieldAssist.ClearButtonSize on the Button rather than the PackIcon * apply TextFieldAssist.ClearButtonSize on the Button rather than the PackIcon --------- Co-authored-by: Corvin Szimion --- .../TextFieldAssist.cs | 26 ++++++++++++++----- .../MaterialDesignTheme.AutoSuggestBox.xaml | 21 +++++++++------ .../Themes/MaterialDesignTheme.ComboBox.xaml | 9 +++++-- .../MaterialDesignTheme.DatePicker.xaml | 1 + .../MaterialDesignTheme.PasswordBox.xaml | 18 ++++++++++--- .../Themes/MaterialDesignTheme.TextBox.xaml | 9 +++++-- 6 files changed, 61 insertions(+), 23 deletions(-) diff --git a/src/MaterialDesignThemes.Wpf/TextFieldAssist.cs b/src/MaterialDesignThemes.Wpf/TextFieldAssist.cs index 3fa0a3b856..aac1a63024 100644 --- a/src/MaterialDesignThemes.Wpf/TextFieldAssist.cs +++ b/src/MaterialDesignThemes.Wpf/TextFieldAssist.cs @@ -41,7 +41,7 @@ public static class TextFieldAssist public static void SetTextBoxViewVerticalAlignment(DependencyObject element, VerticalAlignment value) => element.SetValue(TextBoxViewVerticalAlignmentProperty, value); - public static VerticalAlignment GetTextBoxViewVerticalAlignment(DependencyObject element) => (VerticalAlignment) element.GetValue(TextBoxViewVerticalAlignmentProperty); + public static VerticalAlignment GetTextBoxViewVerticalAlignment(DependencyObject element) => (VerticalAlignment)element.GetValue(TextBoxViewVerticalAlignmentProperty); /// /// Controls the visibility of the underline decoration. @@ -172,7 +172,7 @@ public static void SetSuffixTextVisibility(DependencyObject element, PrefixSuffi => element.SetValue(SuffixTextVisibilityProperty, value); public static PrefixSuffixVisibility GetSuffixTextVisibility(DependencyObject element) - => (PrefixSuffixVisibility) element.GetValue(SuffixTextVisibilityProperty); + => (PrefixSuffixVisibility)element.GetValue(SuffixTextVisibilityProperty); /// /// SuffixTextHintBehavior dependency property. Controls how a floating hint aligns with respect to the text and suffix. @@ -184,7 +184,7 @@ public static void SetSuffixTextHintBehavior(DependencyObject element, PrefixSuf => element.SetValue(SuffixTextHintBehaviorProperty, value); public static PrefixSuffixHintBehavior GetSuffixTextHintBehavior(DependencyObject element) - => (PrefixSuffixHintBehavior) element.GetValue(SuffixTextHintBehaviorProperty); + => (PrefixSuffixHintBehavior)element.GetValue(SuffixTextHintBehaviorProperty); /// /// PrefixText dependency property @@ -208,7 +208,7 @@ public static void SetPrefixTextVisibility(DependencyObject element, PrefixSuffi => element.SetValue(PrefixTextVisibilityProperty, value); public static PrefixSuffixVisibility GetPrefixTextVisibility(DependencyObject element) - => (PrefixSuffixVisibility) element.GetValue(PrefixTextVisibilityProperty); + => (PrefixSuffixVisibility)element.GetValue(PrefixTextVisibilityProperty); /// /// PrefixTextHintBehavior dependency property. Controls how a floating hint aligns with respect to the text and prefix. @@ -234,6 +234,18 @@ public static void SetHasClearButton(DependencyObject element, bool value) public static bool GetHasClearButton(DependencyObject element) => (bool)element.GetValue(HasClearButtonProperty); + /// + /// Controls the size of the clear button. + /// + public static readonly DependencyProperty ClearButtonSizeProperty = DependencyProperty.RegisterAttached( + "ClearButtonSize", typeof(double), typeof(TextFieldAssist), new PropertyMetadata(16.0d)); + + public static void SetClearButtonSize(DependencyObject element, double value) + => element.SetValue(ClearButtonSizeProperty, value); + + public static double GetClearButtonSize(DependencyObject element) + => (double)element.GetValue(ClearButtonSizeProperty); + /// /// Controls visibility of the leading icon /// @@ -316,7 +328,7 @@ public static void SetIconVerticalAlignment(DependencyObject element, VerticalAl => element.SetValue(IconVerticalAlignmentProperty, value); public static VerticalAlignment GetIconVerticalAlignment(DependencyObject element) - => (VerticalAlignment) element.GetValue(IconVerticalAlignmentProperty); + => (VerticalAlignment)element.GetValue(IconVerticalAlignmentProperty); public static Style GetCharacterCounterStyle(DependencyObject obj) => (Style)obj.GetValue(CharacterCounterStyleProperty); @@ -373,14 +385,14 @@ public static Thickness GetOutlinedBorderActiveThickness(DependencyObject elemen public static void SetTextBoxLineCount(DependencyObject element, int value) => element.SetValue(TextBoxLineCountProperty, value); public static int GetTextBoxLineCount(DependencyObject element) - => (int) element.GetValue(TextBoxLineCountProperty); + => (int)element.GetValue(TextBoxLineCountProperty); public static readonly DependencyProperty TextBoxIsMultiLineProperty = DependencyProperty.RegisterAttached( "TextBoxIsMultiLine", typeof(bool), typeof(TextFieldAssist), new PropertyMetadata(false)); public static void SetTextBoxIsMultiLine(DependencyObject element, bool value) => element.SetValue(TextBoxIsMultiLineProperty, value); public static bool GetTextBoxIsMultiLine(DependencyObject element) - => (bool) element.GetValue(TextBoxIsMultiLineProperty); + => (bool)element.GetValue(TextBoxIsMultiLineProperty); #region Methods diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml index ce94fdb964..a8f8f1123f 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml @@ -227,20 +227,25 @@ Visibility="{TemplateBinding wpf:TextFieldAssist.HasTrailingIcon, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" /> diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml index bd56d8c73e..7e0a333041 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml @@ -470,7 +470,8 @@ diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml index c742868407..dd3e686ef0 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DatePicker.xaml @@ -71,6 +71,7 @@ wpf:TextFieldAssist.TrailingIconSize="{TemplateBinding wpf:TextFieldAssist.TrailingIconSize}" wpf:TextFieldAssist.DecorationVisibility="{TemplateBinding wpf:TextFieldAssist.DecorationVisibility}" wpf:TextFieldAssist.HasClearButton="{TemplateBinding wpf:TextFieldAssist.HasClearButton}" + wpf:TextFieldAssist.ClearButtonSize="{TemplateBinding wpf:TextFieldAssist.ClearButtonSize}" wpf:TextFieldAssist.HasFilledTextField="{TemplateBinding wpf:TextFieldAssist.HasFilledTextField}" wpf:TextFieldAssist.HasOutlinedTextField="{TemplateBinding wpf:TextFieldAssist.HasOutlinedTextField}" wpf:TextFieldAssist.NewSpecHighlightingEnabled="{TemplateBinding wpf:TextFieldAssist.NewSpecHighlightingEnabled}" diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml index 38365c2cfc..ff3b415b4f 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml @@ -271,7 +271,8 @@ @@ -898,7 +903,8 @@ diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml index 1093037f9b..a20c25196a 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml @@ -266,7 +266,8 @@ From 070e8bb9fea6e396e372f44f37a5a84adf06439d Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Fri, 10 Jan 2025 07:38:08 +0100 Subject: [PATCH 4/7] [SmartHint] Hint placement for "readonly" controls (#3764) * Demo app workaround/hack for initial miscalculation of hint placement * Ensure ComboBox smart hint behaves according to MD spec According to the "Behavior" section of the "Menus" page in the link below, the hint should float even when there is no selection, but the popup is open. https://m2.material.io/components/menus#exposed-dropdown-menu * Fix hint positioning issue when "readonly" element The issue was present for all controls once they are in "readonly" state. Special handling of the case where the element is readonly, and the hint should follow the prefix/suffix needed to be added because of the "business rule" that prefix/suffix is always visible when the element is "readonly". * Fixing so the hack is no longer needed * Fix AutoSuggestBox as well --------- Co-authored-by: Kevin Bost --- ...ingHintInitialHorizontalOffsetConverter.cs | 13 ++- src/MaterialDesignThemes.Wpf/SmartHint.cs | 2 +- .../MaterialDesignTheme.AutoSuggestBox.xaml | 106 +++++++++--------- .../Themes/MaterialDesignTheme.ComboBox.xaml | 1 + .../MaterialDesignTheme.PasswordBox.xaml | 2 + .../Themes/MaterialDesignTheme.TextBox.xaml | 37 +++--- 6 files changed, 86 insertions(+), 75 deletions(-) diff --git a/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs b/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs index bb1d5a4c88..c9bf535f65 100644 --- a/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs +++ b/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs @@ -19,7 +19,8 @@ public class FloatingHintInitialHorizontalOffsetConverter : IMultiValueConverter PrefixSuffixVisibility suffixVisibility, PrefixSuffixHintBehavior prefixHintBehavior, PrefixSuffixHintBehavior suffixHintBehavior, - HorizontalAlignment horizontalContentAlignment + HorizontalAlignment horizontalContentAlignment, + bool isEditable, ]) { return 0; @@ -37,8 +38,11 @@ double GetLeftOffset() return prefixVisibility switch { PrefixSuffixVisibility.WhenFocusedOrNonEmpty - when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithText => + when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable => prefixWidth + prefixMargin.Right, + PrefixSuffixVisibility.WhenFocusedOrNonEmpty + when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable => + -(prefixWidth + prefixMargin.Right), PrefixSuffixVisibility.Always when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix => -(prefixWidth + prefixMargin.Right), @@ -51,8 +55,11 @@ double GetRightOffset() return suffixVisibility switch { PrefixSuffixVisibility.WhenFocusedOrNonEmpty - when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithText => + when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable => -(suffixWidth + suffixMargin.Left), + PrefixSuffixVisibility.WhenFocusedOrNonEmpty + when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable => + suffixWidth + suffixMargin.Left, PrefixSuffixVisibility.Always when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix => suffixWidth + suffixMargin.Left, diff --git a/src/MaterialDesignThemes.Wpf/SmartHint.cs b/src/MaterialDesignThemes.Wpf/SmartHint.cs index c69eba8aac..41c8245531 100644 --- a/src/MaterialDesignThemes.Wpf/SmartHint.cs +++ b/src/MaterialDesignThemes.Wpf/SmartHint.cs @@ -258,7 +258,7 @@ private void RefreshState(bool useTransitions) string state = string.Empty; bool isEmpty = proxy.IsEmpty(); - bool isFocused = proxy.IsFocused(); + bool isFocused = HintHost?.IsKeyboardFocusWithin ?? proxy.IsFocused(); if (UseFloating) state = !isEmpty || isFocused ? HintFloatingPositionName : HintRestingPositionName; diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml index a8f8f1123f..ece9dd79f4 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.AutoSuggestBox.xaml @@ -71,29 +71,29 @@ + VerticalAlignment="Stretch" + Background="{DynamicResource MaterialDesign.Brush.TextBox.HoverBackground}" + CornerRadius="{TemplateBinding wpf:TextFieldAssist.TextFieldCornerRadius}" + RenderTransformOrigin="0.5,0.5" + Visibility="{TemplateBinding wpf:TextFieldAssist.RippleOnFocusEnabled, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}"> + Padding="{TemplateBinding Padding}" + wpf:BottomDashedLineAdorner.Brush="{TemplateBinding BorderBrush}" + wpf:BottomDashedLineAdorner.Thickness="{Binding RelativeSource={RelativeSource Self}, Path=BorderThickness}" + Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" + CornerRadius="{TemplateBinding wpf:TextFieldAssist.TextFieldCornerRadius}" + SnapsToDevicePixels="True"> + MinHeight="16" + VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> @@ -104,32 +104,14 @@ - - - - - - - - - - - - + Grid.Column="0" + Width="{TemplateBinding wpf:TextFieldAssist.LeadingIconSize}" + Height="{TemplateBinding wpf:TextFieldAssist.LeadingIconSize}" + Margin="0,0,6,0" + VerticalAlignment="{TemplateBinding wpf:TextFieldAssist.IconVerticalAlignment}" + Kind="{TemplateBinding wpf:TextFieldAssist.LeadingIcon}" + Opacity="{TemplateBinding wpf:HintAssist.HintOpacity}" + Visibility="{TemplateBinding wpf:TextFieldAssist.HasLeadingIcon, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" /> + @@ -191,20 +174,38 @@ + Background="{TemplateBinding wpf:HintAssist.Background}" + CornerRadius="2"> + + + + + + + + + + + + + Grid.Column="3" + Margin="2,0,0,0" + VerticalAlignment="Center" + FontSize="{TemplateBinding FontSize}" + Opacity="{TemplateBinding wpf:HintAssist.HintOpacity}" + Text="{TemplateBinding wpf:TextFieldAssist.SuffixText}"> @@ -288,11 +289,10 @@ CornerRadius="{TemplateBinding wpf:TextFieldAssist.UnderlineCornerRadius}" Visibility="{TemplateBinding wpf:TextFieldAssist.DecorationVisibility}" /> - + + Padding="{TemplateBinding Padding, Converter={StaticResource HelperTextMarginConverter}}" + Width="{Binding ActualWidth, ElementName=OuterBorder}"> diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml index 7e0a333041..7b8c0f0fbf 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml @@ -416,6 +416,7 @@ + diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml index ff3b415b4f..d6745207d8 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml @@ -216,6 +216,7 @@ + @@ -836,6 +837,7 @@ + diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml index a20c25196a..52372c0272 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml @@ -151,24 +151,6 @@ Opacity="{TemplateBinding wpf:HintAssist.HintOpacity}" Visibility="{TemplateBinding wpf:TextFieldAssist.HasLeadingIcon, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}" /> - - - - - - - - - - - - + @@ -236,6 +219,24 @@ + + + + + + + + + + + + Date: Thu, 9 Jan 2025 23:32:12 -0800 Subject: [PATCH 5/7] Bumping versions after update Yet another attempt to fix the pipeline --- .github/workflows/get_versions.yml | 6 +++--- .github/workflows/release.yml | 12 +----------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/get_versions.yml b/.github/workflows/get_versions.yml index 85eed9fd22..4a6f9110e5 100644 --- a/.github/workflows/get_versions.yml +++ b/.github/workflows/get_versions.yml @@ -23,9 +23,9 @@ jobs: getting_versions: env: #Update these base version numbers - mdix-version: "5.2.1" - mdix-colors-version: "5.2.1" - mdix-mahapps-version: "5.2.1" + mdix-version: "5.2.2" + mdix-colors-version: "5.2.2" + mdix-mahapps-version: "5.2.2" name: Set version numbers runs-on: ubuntu-latest defaults: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e15959652..844f0aec2b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,17 +10,12 @@ on: env: solution: MaterialDesignToolkit.Full.sln - # Needed for GitHub CLI - GITHUB_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ secrets.SA_PAT }} defaults: run: shell: pwsh -# Needed for updating the version numbers at the end of the pipeline -permissions: - id-token: write - contents: write jobs: get_versions: @@ -277,9 +272,6 @@ jobs: name: Update Version Numbers environment: production - permissions: - actions: write - steps: # Checkout is needed so that we can update the get_versions.yml file - uses: actions/checkout@v4 @@ -313,8 +305,6 @@ jobs: Update-Version -Prefix "mdix-mahapps-version" - name: Open Pull Request - env: - GITHUB_TOKEN: ${{ secrets.SA_PAT }} run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" From 32e258476f72264be1828401c1499b8be3ed0e8d Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Mon, 13 Jan 2025 08:50:44 +0100 Subject: [PATCH 6/7] [SmartHint] Fix minor UI jump (#3768) * Add TextBox.IsReadOnly option to "fields line up" demo pages * Add extra condition in converter to avoid minor UI jump --- src/MainDemo.Wpf/FieldsLineUp.xaml | 1 + src/MainDemo.Wpf/FieldsLineUp.xaml.cs | 2 ++ src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml | 1 + src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs | 2 ++ .../FloatingHintInitialHorizontalOffsetConverter.cs | 4 ++-- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/MainDemo.Wpf/FieldsLineUp.xaml b/src/MainDemo.Wpf/FieldsLineUp.xaml index cc16ac9768..31ac840478 100644 --- a/src/MainDemo.Wpf/FieldsLineUp.xaml +++ b/src/MainDemo.Wpf/FieldsLineUp.xaml @@ -108,6 +108,7 @@ + diff --git a/src/MainDemo.Wpf/FieldsLineUp.xaml.cs b/src/MainDemo.Wpf/FieldsLineUp.xaml.cs index 5ad4bcacac..510c9e0414 100644 --- a/src/MainDemo.Wpf/FieldsLineUp.xaml.cs +++ b/src/MainDemo.Wpf/FieldsLineUp.xaml.cs @@ -52,6 +52,8 @@ public FieldsLineUp() control.Margin = new Thickness(2, 10, 2, 10); if (control is ComboBox comboBox) comboBox.SetBinding(ComboBox.IsEditableProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsEditableCheckBox) }); + if (control is TextBoxBase tb) + tb.SetBinding(TextBoxBase.IsReadOnlyProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsReadOnlyCheckBox) }); SetValue(control); } } diff --git a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml index ed90c7fa03..3f9e2f15a0 100644 --- a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml +++ b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml @@ -97,6 +97,7 @@ + diff --git a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs index 84dfec9f58..094f7c70c6 100644 --- a/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs +++ b/src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs @@ -52,6 +52,8 @@ public FieldsLineUp() control.Margin = new Thickness(2, 10, 2, 10); if (control is ComboBox comboBox) comboBox.SetBinding(ComboBox.IsEditableProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsEditableCheckBox) }); + if (control is TextBoxBase tb) + tb.SetBinding(TextBoxBase.IsReadOnlyProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsReadOnlyCheckBox) }); SetValue(control); } } diff --git a/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs b/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs index c9bf535f65..19981575c5 100644 --- a/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs +++ b/src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs @@ -41,7 +41,7 @@ double GetLeftOffset() when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable => prefixWidth + prefixMargin.Right, PrefixSuffixVisibility.WhenFocusedOrNonEmpty - when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable => + when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable && prefixWidth > 0 => -(prefixWidth + prefixMargin.Right), PrefixSuffixVisibility.Always when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix => @@ -58,7 +58,7 @@ double GetRightOffset() when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable => -(suffixWidth + suffixMargin.Left), PrefixSuffixVisibility.WhenFocusedOrNonEmpty - when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable => + when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable && suffixWidth > 0 => suffixWidth + suffixMargin.Left, PrefixSuffixVisibility.Always when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix => From 0ff7d5da9788321263f47f1e6f354d96af9690e7 Mon Sep 17 00:00:00 2001 From: Joris Voermans Date: Mon, 13 Jan 2025 08:51:16 +0100 Subject: [PATCH 7/7] TextBoxLineCountBehavior: Fixed issue with UpdateAttachedProperties being called after detached causing NullReferenceException (#3769) --- .../Behaviors/TextBoxLineCountBehavior.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/MaterialDesignThemes.Wpf/Behaviors/TextBoxLineCountBehavior.cs b/src/MaterialDesignThemes.Wpf/Behaviors/TextBoxLineCountBehavior.cs index 7940b4e1a6..582294a800 100644 --- a/src/MaterialDesignThemes.Wpf/Behaviors/TextBoxLineCountBehavior.cs +++ b/src/MaterialDesignThemes.Wpf/Behaviors/TextBoxLineCountBehavior.cs @@ -12,8 +12,11 @@ public class TextBoxLineCountBehavior : Behavior private void UpdateAttachedProperties() { - AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxLineCountProperty, AssociatedObject.LineCount); - AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxIsMultiLineProperty, AssociatedObject.LineCount > 1); + if (AssociatedObject != null) + { + AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxLineCountProperty, AssociatedObject.LineCount); + AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxIsMultiLineProperty, AssociatedObject.LineCount > 1); + } } protected override void OnAttached()