From 93a90c901d206617d1ae7f7af5c0aac92afa87f4 Mon Sep 17 00:00:00 2001 From: luotao Date: Tue, 12 May 2026 14:19:48 +0800 Subject: [PATCH 1/3] Upgrade Avalonia Version to 12.0.1 --- src/Avalonia/Directory.Build.props | 4 ++-- .../HandyControlDemo_Avalonia/App.axaml.cs | 14 -------------- .../UserControl/Main/LeftMainContent.axaml | 2 ++ .../UserControl/Main/MainContent.axaml | 2 ++ .../UserControl/Styles/AutoCompleteBoxDemo.axaml | 12 +++++++----- .../UserControl/Styles/ComboBoxDemo.axaml | 9 ++++++--- .../UserControl/Styles/ListBoxDemo.axaml | 4 +++- .../UserControl/Styles/MenuDemo.axaml | 4 +++- .../UserControl/Styles/NumericUpDownDemo.axaml | 4 +++- .../UserControl/Styles/TextBoxDemo.axaml | 12 +++++++----- .../UserControl/Styles/TreeViewDemo.axaml | 4 +++- .../Controls/Other/DashedBorder.cs | 4 ++-- .../Themes/Styles/AutoCompleteBox.axaml | 6 +++--- .../Themes/Styles/ComboBox.axaml | 4 ++-- .../Themes/Styles/NumericUpDown.axaml | 8 ++++---- .../Themes/Styles/OverlayPopupHost.axaml | 4 ++-- .../Themes/Styles/PopupRoot.axaml | 4 ++-- .../Themes/Styles/ProgressBar.axaml | 10 +++++----- .../Themes/Styles/TextBox.axaml | 4 ++-- .../Themes/Styles/Window.axaml | 3 --- 20 files changed, 60 insertions(+), 58 deletions(-) diff --git a/src/Avalonia/Directory.Build.props b/src/Avalonia/Directory.Build.props index 9ed3221f9..336c213bd 100644 --- a/src/Avalonia/Directory.Build.props +++ b/src/Avalonia/Directory.Build.props @@ -1,8 +1,8 @@ - + enable latest net9.0 - 11.3.6 + 12.0.1 diff --git a/src/Avalonia/HandyControlDemo_Avalonia/App.axaml.cs b/src/Avalonia/HandyControlDemo_Avalonia/App.axaml.cs index 78d6b88ed..90d3ab92c 100644 --- a/src/Avalonia/HandyControlDemo_Avalonia/App.axaml.cs +++ b/src/Avalonia/HandyControlDemo_Avalonia/App.axaml.cs @@ -18,7 +18,6 @@ public override void Initialize() public override void OnFrameworkInitializationCompleted() { Properties.Langs.Lang.Culture = new CultureInfo("en"); - RemoveDefaultDataValidator(); if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { @@ -27,17 +26,4 @@ public override void OnFrameworkInitializationCompleted() base.OnFrameworkInitializationCompleted(); } - - private static void RemoveDefaultDataValidator() - { - // Get an array of plugins to remove - var dataValidationPluginsToRemove = - BindingPlugins.DataValidators.OfType().ToArray(); - - // remove each entry found - foreach (var plugin in dataValidationPluginsToRemove) - { - BindingPlugins.DataValidators.Remove(plugin); - } - } } diff --git a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/LeftMainContent.axaml b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/LeftMainContent.axaml index 58cb4fb21..ed917abb2 100644 --- a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/LeftMainContent.axaml +++ b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/LeftMainContent.axaml @@ -3,6 +3,8 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:data="clr-namespace:HandyControlDemo.Data" + xmlns:vm="using:HandyControlDemo.ViewModel" + x:DataType="{x:Type vm:MainViewModel}" Margin="16,16,0,16" CornerRadius="10" Effect="{StaticResource EffectShadow4}"> diff --git a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/MainContent.axaml b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/MainContent.axaml index 7f72e59aa..4fb52c327 100644 --- a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/MainContent.axaml +++ b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Main/MainContent.axaml @@ -1,5 +1,7 @@  diff --git a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/AutoCompleteBoxDemo.axaml b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/AutoCompleteBoxDemo.axaml index 22686e938..1a6bc501f 100644 --- a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/AutoCompleteBoxDemo.axaml +++ b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/AutoCompleteBoxDemo.axaml @@ -1,6 +1,8 @@ - - - - + x:DataType="vm:InputElementDemoViewModel" + x:CompileBindings="False" + DataContext="{Binding InputElementDemo, Source={x:Static vm:ViewModelLocator.Instance}}" + > + diff --git a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/ListBoxDemo.axaml b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/ListBoxDemo.axaml index 4e0bffac3..1b112bb84 100644 --- a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/ListBoxDemo.axaml +++ b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/ListBoxDemo.axaml @@ -1,5 +1,7 @@ - diff --git a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml index 677d506c9..9dbc6c1e0 100644 --- a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml +++ b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml @@ -1,8 +1,10 @@ - - - - + - + - + @@ -11,7 +11,7 @@ - + - + @@ -248,9 +248,9 @@ + Value="{Binding $parent[ProgressBar].Bounds.Width, Converter={StaticResource DoubleExpandConverter}, ConverterParameter=40}" /> + Value="{Binding $parent[ProgressBar].Bounds.Height}" /> @@ -282,9 +282,9 @@ + Value="{Binding $parent[ProgressBar].Bounds.Width}" /> + Value="{Binding $parent[ProgressBar].Bounds.Height, Converter={StaticResource DoubleExpandConverter}, ConverterParameter=40}" /> diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TextBox.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TextBox.axaml index 5bc5a285e..76c55212d 100644 --- a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TextBox.axaml +++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TextBox.axaml @@ -1,4 +1,4 @@ - - + - - - Date: Tue, 12 May 2026 14:48:25 +0800 Subject: [PATCH 2/3] Port SimplePanel to Avalonia --- .../Controls/Panel/SimplePanel.cs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Avalonia/HandyControl_Avalonia/Controls/Panel/SimplePanel.cs diff --git a/src/Avalonia/HandyControl_Avalonia/Controls/Panel/SimplePanel.cs b/src/Avalonia/HandyControl_Avalonia/Controls/Panel/SimplePanel.cs new file mode 100644 index 000000000..6d24ca17d --- /dev/null +++ b/src/Avalonia/HandyControl_Avalonia/Controls/Panel/SimplePanel.cs @@ -0,0 +1,41 @@ +using System; +using Avalonia; +using Avalonia.Controls; + +namespace HandyControl.Controls; + +/// +/// 用以代替Grid +/// +/// +/// 当不需要Grid的行、列分隔等功能时建议用此轻量级类代替 +/// +public class SimplePanel : Panel +{ + protected override Size MeasureOverride(Size constraint) + { + var maxWidth = 0d; + var maxHeight = 0d; + foreach (Control? child in Children) + { + if (child != null) + { + child.Measure(constraint); + maxWidth = Math.Max(maxWidth, child.DesiredSize.Width); + maxHeight = Math.Max(maxHeight, child.DesiredSize.Height); + } + } + + return new Size(maxWidth, maxHeight); + } + + protected override Size ArrangeOverride(Size arrangeSize) + { + foreach (Control? child in Children) + { + child?.Arrange(new Rect(arrangeSize)); + } + + return arrangeSize; + } +} From 9a8c581c5426d7e69f7318962b19f3201b0eb133 Mon Sep 17 00:00:00 2001 From: luotao Date: Tue, 12 May 2026 15:35:35 +0800 Subject: [PATCH 3/3] Replace Watermark by PlaceholderText --- .../UserControl/Styles/NumericUpDownDemo.axaml | 16 ++++++++-------- .../Themes/Styles/AutoCompleteBox.axaml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml index 9dbc6c1e0..527158dbe 100644 --- a/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml +++ b/src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/NumericUpDownDemo.axaml @@ -23,7 +23,7 @@ hc:TitleElement.Title="This is the title" Theme="{StaticResource NumericUpDownExtend}" /> @@ -38,7 +38,7 @@ Value="10000" Width="380" hc:TitleElement.TitleWidth="140" - Watermark="Please enter content" + PlaceholderText="Please enter content" hc:TitleElement.TitlePlacement="Left" hc:TitleElement.Title="The title is on the left" Theme="{StaticResource NumericUpDownExtend}" @@ -61,7 +61,7 @@ hc:TitleElement.Title="This is the title" Theme="{StaticResource NumericUpDownExtend}" /> @@ -76,7 +76,7 @@ hc:InfoElement.ShowClearButton="True" Width="380" hc:TitleElement.TitleWidth="140" - Watermark="Please enter content" + PlaceholderText="Please enter content" hc:TitleElement.TitlePlacement="Left" hc:TitleElement.Title="The title is on the left" Theme="{StaticResource NumericUpDownExtend}" @@ -98,7 +98,7 @@ hc:TitleElement.Title="This is the title" Theme="{StaticResource NumericUpDownExtend.Small}" /> @@ -113,7 +113,7 @@ Value="10000" Width="380" hc:TitleElement.TitleWidth="140" - Watermark="Please enter content" + PlaceholderText="Please enter content" hc:TitleElement.TitlePlacement="Left" hc:TitleElement.Title="The title is on the left" Theme="{StaticResource NumericUpDownExtend.Small}" @@ -136,7 +136,7 @@ hc:TitleElement.Title="This is the title" Theme="{StaticResource NumericUpDownExtend.Small}" /> @@ -151,7 +151,7 @@ hc:InfoElement.ShowClearButton="True" Width="380" hc:TitleElement.TitleWidth="140" - Watermark="Please enter content" + PlaceholderText="Please enter content" hc:TitleElement.TitlePlacement="Left" hc:TitleElement.Title="The title is on the left" Theme="{StaticResource NumericUpDownExtend.Small}" diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/AutoCompleteBox.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/AutoCompleteBox.axaml index dd62ab4d7..dfdfcfc86 100644 --- a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/AutoCompleteBox.axaml +++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/AutoCompleteBox.axaml @@ -41,7 +41,7 @@ CaretIndex="{TemplateBinding CaretIndex, Mode=TwoWay}" ClearSelectionOnLostFocus="{TemplateBinding ClearSelectionOnLostFocus}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" - Watermark="{TemplateBinding Watermark}" + PlaceholderText="{TemplateBinding PlaceholderText}" MaxLength="{TemplateBinding MaxLength}" />