From a96197c8b22cc07d7963b967471a3fcc82ed7a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Sua=CC=81rez=20Ruiz?= Date: Thu, 18 Dec 2025 11:49:47 +0100 Subject: [PATCH 01/11] Added WatermarkForeground property --- .../AutoCompleteBox.Properties.cs | 17 +++++++++++++++++ .../CalendarDatePicker.Properties.cs | 15 +++++++++++++++ .../NumericUpDown/NumericUpDown.cs | 17 +++++++++++++++++ src/Avalonia.Controls/TextBox.cs | 17 +++++++++++++++++ .../Controls/AutoCompleteBox.xaml | 1 + .../Controls/CalendarDatePicker.xaml | 1 + .../Controls/NumericUpDown.xaml | 1 + .../Controls/TextBox.xaml | 17 ++++++----------- .../Controls/AutoCompleteBox.xaml | 1 + .../Controls/CalendarDatePicker.xaml | 3 ++- .../Controls/NumericUpDown.xaml | 1 + .../Controls/TextBox.xaml | 4 +++- 12 files changed, 82 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs index a667087c374..e6e99fe35dd 100644 --- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs @@ -27,6 +27,13 @@ public partial class AutoCompleteBox public static readonly StyledProperty WatermarkProperty = TextBox.WatermarkProperty.AddOwner(); + /// + /// Defines the property. + /// + public static readonly StyledProperty WatermarkForegroundProperty = + TextBox.WatermarkForegroundProperty.AddOwner(); + + /// /// Identifies the property. /// @@ -416,6 +423,16 @@ public string? Watermark set => SetValue(WatermarkProperty, value); } + /// + /// Gets or sets the brush used for the foreground color of the watermark text. + /// + public Media.IBrush? WatermarkForeground + { + get => GetValue(WatermarkForegroundProperty); + set => SetValue(WatermarkForegroundProperty, value); + } + + /// /// Gets or sets the custom method that uses user-entered text to filter /// the items specified by the diff --git a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs index 1454b4ab6cc..0240e6c3a9c 100644 --- a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs +++ b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs @@ -92,6 +92,13 @@ public partial class CalendarDatePicker public static readonly StyledProperty UseFloatingWatermarkProperty = TextBox.UseFloatingWatermarkProperty.AddOwner(); + /// + /// Defines the property. + /// + public static readonly StyledProperty WatermarkForegroundProperty = + TextBox.WatermarkForegroundProperty.AddOwner(); + + /// /// Defines the property. /// @@ -268,6 +275,14 @@ public bool UseFloatingWatermark set => SetValue(UseFloatingWatermarkProperty, value); } + /// + public Media.IBrush? WatermarkForeground + { + get => GetValue(WatermarkForegroundProperty); + set => SetValue(WatermarkForegroundProperty, value); + } + + /// /// Gets or sets the horizontal alignment of the content within the control. /// diff --git a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs index 188497d230a..62c69165d4a 100644 --- a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs +++ b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs @@ -114,6 +114,13 @@ public class NumericUpDown : TemplatedControl public static readonly StyledProperty WatermarkProperty = AvaloniaProperty.Register(nameof(Watermark)); + /// + /// Defines the property. + /// + public static readonly StyledProperty WatermarkForegroundProperty = + TextBox.WatermarkForegroundProperty.AddOwner(); + + /// /// Defines the property. /// @@ -300,6 +307,16 @@ public string? Watermark set => SetValue(WatermarkProperty, value); } + /// + /// Gets or sets the brush used for the foreground color of the watermark text. + /// + public Media.IBrush? WatermarkForeground + { + get => GetValue(WatermarkForegroundProperty); + set => SetValue(WatermarkForegroundProperty, value); + } + + /// /// Gets or sets the horizontal alignment of the content within the control. /// diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index b5017226766..7bf000fd012 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -192,6 +192,13 @@ public class TextBox : TemplatedControl, UndoRedoHelper.I public static readonly StyledProperty UseFloatingWatermarkProperty = AvaloniaProperty.Register(nameof(UseFloatingWatermark)); + /// + /// Defines the property + /// + public static readonly StyledProperty WatermarkForegroundProperty = + AvaloniaProperty.Register(nameof(WatermarkForeground)); + + /// /// Defines the property /// @@ -681,6 +688,16 @@ public bool UseFloatingWatermark set => SetValue(UseFloatingWatermarkProperty, value); } + /// + /// Gets or sets the brush used for the foreground color of the watermark text. + /// + public IBrush? WatermarkForeground + { + get => GetValue(WatermarkForegroundProperty); + set => SetValue(WatermarkForegroundProperty, value); + } + + /// /// Gets or sets custom content that is positioned on the left side of the text layout box /// diff --git a/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml b/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml index 3196d262a17..f0879e3288b 100644 --- a/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml @@ -35,6 +35,7 @@ + @@ -133,10 +134,11 @@ Grid.ColumnSpan="1" Margin="{TemplateBinding Padding}"> + + - @@ -217,19 +218,12 @@ - - + - diff --git a/src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml b/src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml index bcba6464611..6263d738d59 100644 --- a/src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml @@ -126,7 +126,7 @@ Foreground="{TemplateBinding Foreground}" Background="Transparent" Text="{TemplateBinding Text, Mode=TwoWay}" - Watermark="{TemplateBinding PlaceholderText}" + Placeholder="{TemplateBinding PlaceholderText}" BorderThickness="0" IsVisible="{TemplateBinding IsEditable}"> diff --git a/src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml b/src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml index 598cec7ace3..c1dfe8d4a3d 100644 --- a/src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml @@ -184,7 +184,7 @@ IsVisible="{Binding ShowFilters}" ItemsSource="{Binding Filters}" SelectedItem="{Binding SelectedFilter}" /> - + diff --git a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml index b9acbc35cd7..ff854b40a83 100644 --- a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml @@ -8,14 +8,14 @@ + Placeholder="Enter text" /> + Placeholder="Enter text" /> Clear Reveal Password Password Revealed - - - Content + + + Content @@ -99,7 +99,7 @@ - + @@ -133,10 +133,10 @@ Grid.Column="1" Grid.ColumnSpan="1" Margin="{TemplateBinding Padding}"> - - - - diff --git a/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml b/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml index fa20725e214..2e7c1687e99 100644 --- a/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml +++ b/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml @@ -14,7 +14,7 @@ Copy Paste - File name + File name Show hidden files OK Cancel diff --git a/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml b/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml index b9590f0dc12..a8da9116747 100644 --- a/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml +++ b/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml @@ -19,8 +19,8 @@ CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}" ClearSelectionOnLostFocus="{TemplateBinding ClearSelectionOnLostFocus}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" - Watermark="{TemplateBinding Watermark}" - WatermarkForeground="{TemplateBinding WatermarkForeground}" + Placeholder="{TemplateBinding Placeholder}" + PlaceholderForeground="{TemplateBinding PlaceholderForeground}" MaxLength="{TemplateBinding MaxLength}" InnerLeftContent="{TemplateBinding InnerLeftContent}" InnerRightContent="{TemplateBinding InnerRightContent}" diff --git a/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml b/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml index 081d7be3f00..386728eca39 100644 --- a/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml +++ b/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml @@ -101,9 +101,9 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" - UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}" - Watermark="{TemplateBinding Watermark}" - WatermarkForeground="{TemplateBinding WatermarkForeground}" /> + UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}" + Placeholder="{TemplateBinding Placeholder}" + PlaceholderForeground="{TemplateBinding PlaceholderForeground}" /> - + !BooleanString !!BooleanString @@ -43,24 +43,24 @@ - + - - - - + - + @@ -91,19 +91,19 @@ - + - + - - + + - + - - + + diff --git a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml index 487b638a1f8..35e917f9961 100644 --- a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml +++ b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml @@ -39,12 +39,12 @@ - - + + - - + + diff --git a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml index c6b7e3910d0..2975255e8b2 100644 --- a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml +++ b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml @@ -5,7 +5,7 @@ x:Class="ControlCatalog.Pages.CalendarDatePickerPage"> A control for selecting dates with a calendar drop-down - + + PlaceholderText="Placeholder"/> + PlaceholderText="Floating Placeholder" + UseFloatingPlaceholderText="True"/> - + - + - + - + diff --git a/samples/ControlCatalog/Pages/ClipboardPage.xaml b/samples/ControlCatalog/Pages/ClipboardPage.xaml index 99bc527abf8..864a520aca8 100644 --- a/samples/ControlCatalog/Pages/ClipboardPage.xaml +++ b/samples/ControlCatalog/Pages/ClipboardPage.xaml @@ -1,4 +1,4 @@ - @@ -21,7 +21,7 @@ + PlaceholderText="Text to copy of file names per line" /> diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml b/samples/ControlCatalog/Pages/DialogsPage.xaml index 9b93ece1b56..f32cc601ab7 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml @@ -58,17 +58,17 @@ - + - + - + Desktop @@ -80,17 +80,17 @@ - + - + + PlaceholderText="Picked file content" /> diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml index fbce9ec3e14..a112f79c02c 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml @@ -1,4 +1,4 @@ - - Placeholder: - + PlaceholderText: + Text: @@ -81,23 +81,23 @@ + PlaceholderText="Enter text" FormatString="{Binding SelectedFormat.Value}"/> + PlaceholderText="Enter text" FormatString="{Binding SelectedFormat.Value}"/> - + + PlaceholderText="Enter text" FormatString="{Binding SelectedFormat.Value}"> - + @@ -110,7 +110,7 @@ - + @@ -118,7 +118,7 @@ - - + + - + - + - + + SelectionStart="5" SelectionEnd="22" + SelectionBrush="Green" SelectionForegroundBrush="Yellow" ClearSelectionOnLostFocus="False"/> @@ -61,11 +61,11 @@ - + + FontFamily="Comic Sans MS" + FontSize="10" + Foreground="Red"/> - diff --git a/samples/ControlCatalog/Pages/ThemePage.axaml b/samples/ControlCatalog/Pages/ThemePage.axaml index db6025ea4af..7eb95471a05 100644 --- a/samples/ControlCatalog/Pages/ThemePage.axaml +++ b/samples/ControlCatalog/Pages/ThemePage.axaml @@ -1,4 +1,4 @@ - - - + + @@ -184,7 +184,7 @@ IsVisible="{Binding ShowFilters}" ItemsSource="{Binding Filters}" SelectedItem="{Binding SelectedFilter}" /> - + @@ -344,7 +344,7 @@ - + diff --git a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml index ff854b40a83..b6c19484e95 100644 --- a/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml @@ -1,21 +1,21 @@ - + - + Maximum="10" + Increment="0.5" + VerticalContentAlignment="Center" + HorizontalContentAlignment="Center" + ButtonSpinnerLocation="Left" + PlaceholderText="Enter text" /> Clear Reveal Password Password Revealed - - - Content + + + Content @@ -20,7 +20,7 @@ M 11.416016,10 20,1.4160156 18.583984,0 10,8.5839846 1.4160156,0 0,1.4160156 8.5839844,10 0,18.583985 1.4160156,20 10,11.416015 18.583984,20 20,18.583985 Z m10.051 7.0032c2.215 0 4.0105 1.7901 4.0105 3.9984s-1.7956 3.9984-4.0105 3.9984c-2.215 0-4.0105-1.7901-4.0105-3.9984s1.7956-3.9984 4.0105-3.9984zm0 1.4994c-1.3844 0-2.5066 1.1188-2.5066 2.499s1.1222 2.499 2.5066 2.499 2.5066-1.1188 2.5066-2.499-1.1222-2.499-2.5066-2.499zm0-5.0026c4.6257 0 8.6188 3.1487 9.7267 7.5613 0.10085 0.40165-0.14399 0.80877-0.54686 0.90931-0.40288 0.10054-0.81122-0.14355-0.91208-0.54521-0.94136-3.7492-4.3361-6.4261-8.2678-6.4261-3.9334 0-7.3292 2.6792-8.2689 6.4306-0.10063 0.40171-0.50884 0.64603-0.91177 0.54571s-0.648-0.5073-0.54737-0.90901c1.106-4.4152 5.1003-7.5667 9.728-7.5667z m0.21967 0.21965c-0.26627 0.26627-0.29047 0.68293-0.07262 0.97654l0.07262 0.08412 4.0346 4.0346c-1.922 1.3495-3.3585 3.365-3.9554 5.7495-0.10058 0.4018 0.14362 0.8091 0.54543 0.9097 0.40182 0.1005 0.80909-0.1436 0.90968-0.5455 0.52947-2.1151 1.8371-3.8891 3.5802-5.0341l1.8096 1.8098c-0.70751 0.7215-1.1438 1.71-1.1438 2.8003 0 2.2092 1.7909 4 4 4 1.0904 0 2.0788-0.4363 2.8004-1.1438l5.9193 5.9195c0.2929 0.2929 0.7677 0.2929 1.0606 0 0.2663-0.2662 0.2905-0.6829 0.0726-0.9765l-0.0726-0.0841-6.1135-6.1142 0.0012-0.0015-1.2001-1.1979-2.8699-2.8693 2e-3 -8e-4 -2.8812-2.8782 0.0012-0.0018-1.1333-1.1305-4.3064-4.3058c-0.29289-0.29289-0.76777-0.29289-1.0607 0zm7.9844 9.0458 3.5351 3.5351c-0.45 0.4358-1.0633 0.704-1.7392 0.704-1.3807 0-2.5-1.1193-2.5-2.5 0-0.6759 0.26824-1.2892 0.7041-1.7391zm1.7959-5.7655c-1.0003 0-1.9709 0.14807-2.8889 0.425l1.237 1.2362c0.5358-0.10587 1.0883-0.16119 1.6519-0.16119 3.9231 0 7.3099 2.6803 8.2471 6.4332 0.1004 0.4018 0.5075 0.6462 0.9094 0.5459 0.4019-0.1004 0.6463-0.5075 0.5459-0.9094-1.103-4.417-5.0869-7.5697-9.7024-7.5697zm0.1947 3.5093 3.8013 3.8007c-0.1018-2.0569-1.7488-3.7024-3.8013-3.8007z - + @@ -136,7 +136,7 @@ - - diff --git a/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml b/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml index a8da9116747..ec0eccc8c42 100644 --- a/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml +++ b/src/Avalonia.Themes.Simple/Controls/AutoCompleteBox.xaml @@ -19,9 +19,9 @@ CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}" ClearSelectionOnLostFocus="{TemplateBinding ClearSelectionOnLostFocus}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" - Placeholder="{TemplateBinding Placeholder}" + PlaceholderText="{TemplateBinding PlaceholderText}" PlaceholderForeground="{TemplateBinding PlaceholderForeground}" - MaxLength="{TemplateBinding MaxLength}" + MaxLength="{TemplateBinding MaxLength}" InnerLeftContent="{TemplateBinding InnerLeftContent}" InnerRightContent="{TemplateBinding InnerRightContent}" /> diff --git a/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml b/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml index 386728eca39..e49905eff48 100644 --- a/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml +++ b/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml @@ -101,8 +101,8 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" - UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}" - Placeholder="{TemplateBinding Placeholder}" + UseFloatingPlaceholderText="{TemplateBinding UseFloatingPlaceholderText}" + PlaceholderText="{TemplateBinding PlaceholderText}" PlaceholderForeground="{TemplateBinding PlaceholderForeground}" /> [Obsolete("Use PlaceholderTextProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkProperty = PlaceholderTextProperty; /// /// Defines the property. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013", + Justification = "We keep WatermarkForegroundProperty for backward compatibility.")] public static readonly StyledProperty PlaceholderForegroundProperty = TextBox.PlaceholderForegroundProperty.AddOwner(); @@ -46,6 +52,8 @@ public partial class AutoCompleteBox /// Defines the property. /// [Obsolete("Use PlaceholderForegroundProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkForegroundProperty = PlaceholderForegroundProperty; /// @@ -447,6 +455,8 @@ public string? PlaceholderText public string? Watermark { get => PlaceholderText; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderText = value; } @@ -466,6 +476,8 @@ public Media.IBrush? PlaceholderForeground public Media.IBrush? WatermarkForeground { get => PlaceholderForeground; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderForeground = value; } diff --git a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs index ffab7e880bb..160ce031e2f 100644 --- a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs +++ b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs @@ -83,6 +83,8 @@ public partial class CalendarDatePicker /// /// Defines the property. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013", + Justification = "We keep WatermarkProperty for backward compatibility.")] public static readonly StyledProperty PlaceholderTextProperty = TextBox.PlaceholderTextProperty.AddOwner(); @@ -90,11 +92,15 @@ public partial class CalendarDatePicker /// Defines the property. /// [Obsolete("Use PlaceholderTextProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkProperty = PlaceholderTextProperty; /// /// Defines the property. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013", + Justification = "We keep UseFloatingWatermarkProperty for backward compatibility.")] public static readonly StyledProperty UseFloatingPlaceholderTextProperty = TextBox.UseFloatingPlaceholderTextProperty.AddOwner(); @@ -102,11 +108,15 @@ public partial class CalendarDatePicker /// Defines the property. /// [Obsolete("Use UseFloatingPlaceholderTextProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty UseFloatingWatermarkProperty = UseFloatingPlaceholderTextProperty; /// /// Defines the property. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013", + Justification = "We keep WatermarkForegroundProperty for backward compatibility.")] public static readonly StyledProperty PlaceholderForegroundProperty = TextBox.PlaceholderForegroundProperty.AddOwner(); @@ -114,6 +124,8 @@ public partial class CalendarDatePicker /// Defines the property. /// [Obsolete("Use PlaceholderForegroundProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkForegroundProperty = PlaceholderForegroundProperty; /// @@ -290,6 +302,8 @@ public string? PlaceholderText public string? Watermark { get => PlaceholderText; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderText = value; } @@ -305,6 +319,8 @@ public bool UseFloatingPlaceholderText public bool UseFloatingWatermark { get => UseFloatingPlaceholderText; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => UseFloatingPlaceholderText = value; } @@ -320,6 +336,8 @@ public Media.IBrush? PlaceholderForeground public Media.IBrush? WatermarkForeground { get => PlaceholderForeground; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderForeground = value; } diff --git a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs index 453c7524c2a..ab3861db474 100644 --- a/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs +++ b/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs @@ -118,11 +118,15 @@ public class NumericUpDown : TemplatedControl /// Defines the property. /// [Obsolete("Use PlaceholderTextProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkProperty = PlaceholderTextProperty; /// /// Defines the property. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013", + Justification = "We keep WatermarkForegroundProperty for backward compatibility.")] public static readonly StyledProperty PlaceholderForegroundProperty = TextBox.PlaceholderForegroundProperty.AddOwner(); @@ -130,6 +134,8 @@ public class NumericUpDown : TemplatedControl /// Defines the property. /// [Obsolete("Use PlaceholderForegroundProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkForegroundProperty = PlaceholderForegroundProperty; /// @@ -325,6 +331,8 @@ public string? PlaceholderText public string? Watermark { get => PlaceholderText; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderText = value; } @@ -344,6 +352,8 @@ public Media.IBrush? PlaceholderForeground public Media.IBrush? WatermarkForeground { get => PlaceholderForeground; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderForeground = value; } diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 58af074c654..42aaecdda77 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -190,6 +190,8 @@ public class TextBox : TemplatedControl, UndoRedoHelper.I /// Defines the property. /// [Obsolete("Use PlaceholderTextProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkProperty = PlaceholderTextProperty; /// @@ -202,6 +204,8 @@ public class TextBox : TemplatedControl, UndoRedoHelper.I /// Defines the property. /// [Obsolete("Use UseFloatingPlaceholderTextProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty UseFloatingWatermarkProperty = UseFloatingPlaceholderTextProperty; /// @@ -214,6 +218,8 @@ public class TextBox : TemplatedControl, UndoRedoHelper.I /// Defines the property. /// [Obsolete("Use PlaceholderForegroundProperty instead.", false)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", + Justification = "Obsolete property alias for backward compatibility.")] public static readonly StyledProperty WatermarkForegroundProperty = PlaceholderForegroundProperty; /// @@ -703,6 +709,8 @@ public string? PlaceholderText public string? Watermark { get => PlaceholderText; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderText = value; } @@ -724,6 +732,8 @@ public bool UseFloatingPlaceholderText public bool UseFloatingWatermark { get => UseFloatingPlaceholderText; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => UseFloatingPlaceholderText = value; } @@ -743,6 +753,8 @@ public IBrush? PlaceholderForeground public IBrush? WatermarkForeground { get => PlaceholderForeground; + [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", + Justification = "Obsolete property setter for backward compatibility.")] set => PlaceholderForeground = value; } From be2a8c8bf23d6ce7bac8e2f1d2d589114b9dcfe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Sua=CC=81rez=20Ruiz?= Date: Thu, 5 Feb 2026 16:19:01 +0100 Subject: [PATCH 10/11] Use UseFloatingPlaceholder --- samples/BindingDemo/MainWindow.xaml | 30 +++++++++---------- .../Pages/CalendarDatePickerPage.xaml | 2 +- samples/ControlCatalog/Pages/TextBoxPage.xaml | 6 ++-- .../Controls/SignUpView.xaml | 6 ++-- .../Pages/ScreensPage.axaml | 14 ++++----- .../CalendarDatePicker.Properties.cs | 24 +++++++-------- .../CalendarDatePicker/CalendarDatePicker.cs | 2 +- src/Avalonia.Controls/TextBox.cs | 22 +++++++------- .../Controls/CalendarDatePicker.xaml | 2 +- .../Controls/TextBox.xaml | 6 ++-- .../Controls/CalendarDatePicker.xaml | 2 +- .../Controls/TextBox.xaml | 2 +- 12 files changed, 59 insertions(+), 59 deletions(-) diff --git a/samples/BindingDemo/MainWindow.xaml b/samples/BindingDemo/MainWindow.xaml index 7fc9014b8ba..3ff80069f46 100644 --- a/samples/BindingDemo/MainWindow.xaml +++ b/samples/BindingDemo/MainWindow.xaml @@ -20,22 +20,22 @@ - - - - + + + + - + - + !BooleanString !!BooleanString @@ -43,17 +43,17 @@ - + - - - @@ -93,17 +93,17 @@ - + - - + + - - + + diff --git a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml index 2975255e8b2..8734758d263 100644 --- a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml +++ b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml @@ -36,7 +36,7 @@ + UseFloatingPlaceholder="True"/> @@ -42,7 +42,7 @@ PlaceholderText="Password Box" Classes="revealPasswordButton" TextInputOptions.ContentType="Password" - UseFloatingPlaceholderText="True" + UseFloatingPlaceholder="True" PasswordChar="*" Text="Password" /> diff --git a/samples/Generators.Sandbox/Controls/SignUpView.xaml b/samples/Generators.Sandbox/Controls/SignUpView.xaml index 5bcb16ee53c..09313705f40 100644 --- a/samples/Generators.Sandbox/Controls/SignUpView.xaml +++ b/samples/Generators.Sandbox/Controls/SignUpView.xaml @@ -18,7 +18,7 @@ x:Name="UserNameTextBox" Text="{Binding UserName}" PlaceholderText="Please, enter user name..." - UseFloatingPlaceholderText="True" /> + UseFloatingPlaceholder="True" /> - - - - - - - + + + + + + + diff --git a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs index 160ce031e2f..864ba86ef08 100644 --- a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs +++ b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.Properties.cs @@ -97,20 +97,20 @@ public partial class CalendarDatePicker public static readonly StyledProperty WatermarkProperty = PlaceholderTextProperty; /// - /// Defines the property. + /// Defines the property. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1013", Justification = "We keep UseFloatingWatermarkProperty for backward compatibility.")] - public static readonly StyledProperty UseFloatingPlaceholderTextProperty = - TextBox.UseFloatingPlaceholderTextProperty.AddOwner(); + public static readonly StyledProperty UseFloatingPlaceholderProperty = + TextBox.UseFloatingPlaceholderProperty.AddOwner(); /// /// Defines the property. /// - [Obsolete("Use UseFloatingPlaceholderTextProperty instead.", false)] + [Obsolete("Use UseFloatingPlaceholderProperty instead.", false)] [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", Justification = "Obsolete property alias for backward compatibility.")] - public static readonly StyledProperty UseFloatingWatermarkProperty = UseFloatingPlaceholderTextProperty; + public static readonly StyledProperty UseFloatingWatermarkProperty = UseFloatingPlaceholderProperty; /// /// Defines the property. @@ -307,21 +307,21 @@ public string? Watermark set => PlaceholderText = value; } - /// - public bool UseFloatingPlaceholderText + /// + public bool UseFloatingPlaceholder { - get => GetValue(UseFloatingPlaceholderTextProperty); - set => SetValue(UseFloatingPlaceholderTextProperty, value); + get => GetValue(UseFloatingPlaceholderProperty); + set => SetValue(UseFloatingPlaceholderProperty, value); } /// - [Obsolete("Use UseFloatingPlaceholderText instead.", false)] + [Obsolete("Use UseFloatingPlaceholder instead.", false)] public bool UseFloatingWatermark { - get => UseFloatingPlaceholderText; + get => UseFloatingPlaceholder; [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", Justification = "Obsolete property setter for backward compatibility.")] - set => UseFloatingPlaceholderText = value; + set => UseFloatingPlaceholder = value; } /// diff --git a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs index a37c3b2d53d..c07d43b77c0 100644 --- a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs +++ b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs @@ -881,7 +881,7 @@ private void SetWaterMarkText() { SetCurrentValue(TextProperty, String.Empty); - if (string.IsNullOrEmpty(PlaceholderText) && !UseFloatingPlaceholderText) + if (string.IsNullOrEmpty(PlaceholderText) && !UseFloatingPlaceholder) { DateTimeFormatInfo dtfi = DateTimeHelper.GetCurrentDateFormat(); _defaultText = string.Empty; diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 42aaecdda77..447a6a41fcf 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -195,18 +195,18 @@ public class TextBox : TemplatedControl, UndoRedoHelper.I public static readonly StyledProperty WatermarkProperty = PlaceholderTextProperty; /// - /// Defines the property. + /// Defines the property. /// - public static readonly StyledProperty UseFloatingPlaceholderTextProperty = - AvaloniaProperty.Register(nameof(UseFloatingPlaceholderText)); + public static readonly StyledProperty UseFloatingPlaceholderProperty = + AvaloniaProperty.Register(nameof(UseFloatingPlaceholder)); /// /// Defines the property. /// - [Obsolete("Use UseFloatingPlaceholderTextProperty instead.", false)] + [Obsolete("Use UseFloatingPlaceholderProperty instead.", false)] [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1022", Justification = "Obsolete property alias for backward compatibility.")] - public static readonly StyledProperty UseFloatingWatermarkProperty = UseFloatingPlaceholderTextProperty; + public static readonly StyledProperty UseFloatingWatermarkProperty = UseFloatingPlaceholderProperty; /// /// Defines the property. @@ -718,23 +718,23 @@ public string? Watermark /// Gets or sets a value indicating whether the will still be shown above the /// even after a text value is set. /// - public bool UseFloatingPlaceholderText + public bool UseFloatingPlaceholder { - get => GetValue(UseFloatingPlaceholderTextProperty); - set => SetValue(UseFloatingPlaceholderTextProperty, value); + get => GetValue(UseFloatingPlaceholderProperty); + set => SetValue(UseFloatingPlaceholderProperty, value); } /// /// Gets or sets a value indicating whether the will still be shown above the /// even after a text value is set. /// - [Obsolete("Use UseFloatingPlaceholderText instead.", false)] + [Obsolete("Use UseFloatingPlaceholder instead.", false)] public bool UseFloatingWatermark { - get => UseFloatingPlaceholderText; + get => UseFloatingPlaceholder; [System.Diagnostics.CodeAnalysis.SuppressMessage("AvaloniaProperty", "AVP1012", Justification = "Obsolete property setter for backward compatibility.")] - set => UseFloatingPlaceholderText = value; + set => UseFloatingPlaceholder = value; } /// diff --git a/src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml index b8914f74237..3a8db8ae361 100644 --- a/src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml @@ -94,7 +94,7 @@ Padding="{TemplateBinding Padding}" PlaceholderText="{TemplateBinding PlaceholderText}" PlaceholderForeground="{TemplateBinding PlaceholderForeground}" - UseFloatingPlaceholderText="{TemplateBinding UseFloatingPlaceholderText}" + UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" diff --git a/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml b/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml index b420d4ff01c..5cd5f84204d 100644 --- a/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml @@ -10,8 +10,8 @@ Reveal Password Password Revealed - - Content + + Content @@ -239,7 +239,7 @@ - diff --git a/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml b/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml index e49905eff48..a38f6f912dc 100644 --- a/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml +++ b/src/Avalonia.Themes.Simple/Controls/CalendarDatePicker.xaml @@ -101,7 +101,7 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" - UseFloatingPlaceholderText="{TemplateBinding UseFloatingPlaceholderText}" + UseFloatingPlaceholder="{TemplateBinding UseFloatingPlaceholder}" PlaceholderText="{TemplateBinding PlaceholderText}" PlaceholderForeground="{TemplateBinding PlaceholderForeground}" /> diff --git a/src/Avalonia.Themes.Simple/Controls/TextBox.xaml b/src/Avalonia.Themes.Simple/Controls/TextBox.xaml index 6e56e4a3103..f49e6317d0e 100644 --- a/src/Avalonia.Themes.Simple/Controls/TextBox.xaml +++ b/src/Avalonia.Themes.Simple/Controls/TextBox.xaml @@ -110,7 +110,7 @@ Text="{TemplateBinding PlaceholderText}"> - Date: Thu, 5 Feb 2026 16:34:46 +0100 Subject: [PATCH 11/11] Fix tests --- tests/Avalonia.RenderTests/Controls/TextBoxTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Avalonia.RenderTests/Controls/TextBoxTests.cs b/tests/Avalonia.RenderTests/Controls/TextBoxTests.cs index 6e8608b8b10..8047f2d103e 100644 --- a/tests/Avalonia.RenderTests/Controls/TextBoxTests.cs +++ b/tests/Avalonia.RenderTests/Controls/TextBoxTests.cs @@ -29,6 +29,9 @@ private static IControlTemplate CreateTextBoxTemplate() var panel = new Panel(); + // Use Antialias mode + TextOptions.SetTextRenderingMode(panel, TextRenderingMode.Antialias); + var placeholder = new TextBlock { Name = "PART_Placeholder",