From 8142dd48cd98e7b67c5d62d7ef94a0c0a0014996 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:00:20 +0800 Subject: [PATCH] feat: ComboBox BackgroundSizing. --- .../Pages/ComboBoxDemo.axaml | 95 +++++++------------ .../Pages/ComboBoxDemo.axaml.cs | 10 +- src/Semi.Avalonia/Controls/ComboBox.axaml | 9 +- 3 files changed, 45 insertions(+), 69 deletions(-) diff --git a/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml index 488a8ff..3bf4425 100644 --- a/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml @@ -4,71 +4,40 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - d:DesignHeight="450" + xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages" + d:DesignHeight="800" d:DesignWidth="800" mc:Ignorable="d"> + + + - - Ding - Otter - Husky - Mr. 17 - Cass - - - Ding - Otter - Husky - Mr. 17 - Cass - - - Ding - Otter - Husky - Mr. 17 - Cass - - - Ding - Otter - Husky - Mr. 17 - Cass - - - Ding - Otter - Husky - Mr. 17 - Cass - - - Ding - Otter - Husky - Mr. 17 - Cass - - - Ding - Otter - Husky - Mr. 17 - Cass - - - Ding - Otter - Husky - Mr. 17 - Cass - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml.cs index 80b05bc..3c8cba2 100644 --- a/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Pages/ComboBoxDemo.axaml.cs @@ -1,6 +1,6 @@ -using Avalonia; +using System.Collections.ObjectModel; using Avalonia.Controls; -using Avalonia.Markup.Xaml; +using CommunityToolkit.Mvvm.ComponentModel; namespace Semi.Avalonia.Demo.Pages; @@ -9,5 +9,11 @@ public partial class ComboBoxDemo : UserControl public ComboBoxDemo() { InitializeComponent(); + this.DataContext = new ComboBoxDemoViewModel(); } +} + +public class ComboBoxDemoViewModel : ObservableObject +{ + public ObservableCollection Items { get; set; } = ["Ding", "Otter", "Husky", "Mr.17", "Cass"]; } \ No newline at end of file diff --git a/src/Semi.Avalonia/Controls/ComboBox.axaml b/src/Semi.Avalonia/Controls/ComboBox.axaml index b59da08..b37c66e 100644 --- a/src/Semi.Avalonia/Controls/ComboBox.axaml +++ b/src/Semi.Avalonia/Controls/ComboBox.axaml @@ -32,6 +32,7 @@ + @@ -41,6 +42,7 @@ + @@ -49,9 +51,8 @@ x:Name="Background" Grid.Column="0" Grid.ColumnSpan="3" - MinWidth="{DynamicResource ComboBoxThemeMinWidth}" - MinHeight="{DynamicResource ComboBoxDefaultHeight}" Background="{TemplateBinding Background}" + BackgroundSizing="{TemplateBinding BackgroundSizing}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" /> @@ -147,10 +148,10 @@ - -