feat: ComboBox BackgroundSizing.
This commit is contained in:
parent
76c9b57a4b
commit
8142dd48cd
@ -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">
|
||||
<Design.DataContext>
|
||||
<pages:ComboBoxDemoViewModel />
|
||||
</Design.DataContext>
|
||||
<StackPanel Spacing="20">
|
||||
<ComboBox Width="150">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox Width="150" Classes="ClearButton">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox Width="150" PlaceholderText="Please Select">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox Width="150" IsEnabled="False">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox
|
||||
Width="150"
|
||||
Classes="Large"
|
||||
IsEnabled="False">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox Width="150" Classes="Small">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox Width="150" Classes="Bordered">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox
|
||||
Width="150"
|
||||
Classes="Bordered"
|
||||
IsEnabled="False">
|
||||
<ComboBoxItem>Ding</ComboBoxItem>
|
||||
<ComboBoxItem>Otter</ComboBoxItem>
|
||||
<ComboBoxItem>Husky</ComboBoxItem>
|
||||
<ComboBoxItem>Mr. 17</ComboBoxItem>
|
||||
<ComboBoxItem>Cass</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<StackPanel.Styles>
|
||||
<Style Selector="ComboBox">
|
||||
<Setter Property="Width" Value="300" />
|
||||
<Setter Property="ItemsSource" Value="{Binding Items}" />
|
||||
</Style>
|
||||
</StackPanel.Styles>
|
||||
|
||||
<ComboBox />
|
||||
<ComboBox Classes="ClearButton" />
|
||||
<ComboBox PlaceholderText="Please Select" />
|
||||
<ComboBox IsEnabled="False" />
|
||||
<ComboBox Classes="Large" IsEnabled="False" />
|
||||
<ComboBox Classes="Small" />
|
||||
<ComboBox Classes="Bordered" />
|
||||
<ComboBox Classes="Bordered" IsEnabled="False" />
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ComboBox Width="100" Classes="Large" PlaceholderText="Large" />
|
||||
<ComboBox Width="100" PlaceholderText="Default" />
|
||||
<ComboBox Width="100" Classes="Small" PlaceholderText="Small" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ComboBox Width="100" IsEnabled="False" PlaceholderText="Disabled" />
|
||||
<ComboBox Width="100" Classes="Bordered" PlaceholderText="Bordered" />
|
||||
<ComboBox Width="100" Classes="Bordered" IsEnabled="False" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
@ -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<string> Items { get; set; } = ["Ding", "Otter", "Husky", "Mr.17", "Cass"];
|
||||
}
|
@ -32,6 +32,7 @@
|
||||
<Setter Property="FocusAdorner" Value="{x:Null}" />
|
||||
<Setter Property="MaxDropDownHeight" Value="504" />
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" />
|
||||
<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" />
|
||||
@ -41,6 +42,7 @@
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxDefaultHeight}" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="ComboBox">
|
||||
<DataValidationErrors>
|
||||
@ -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 @@
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^.Large /template/ Border#Background">
|
||||
<Style Selector="^.Large">
|
||||
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxLargeHeight}" />
|
||||
</Style>
|
||||
<Style Selector="^.Small /template/ Border#Background">
|
||||
<Style Selector="^.Small">
|
||||
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxSmallHeight}" />
|
||||
</Style>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user