From df3c6d5498cfa265811384ebaefcc236aaa550da Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Thu, 2 Jul 2020 15:54:06 -0400 Subject: [PATCH] Add HorizontalContentAlignment and VerticalContentAlignment to ComboBox default and fluent style --- src/Avalonia.Controls/ComboBox.cs | 31 +++++++++++++++++ src/Avalonia.Themes.Default/ComboBox.xaml | 42 +++++++++++++++++------ src/Avalonia.Themes.Fluent/ComboBox.xaml | 16 +++++---- 3 files changed, 72 insertions(+), 17 deletions(-) diff --git a/src/Avalonia.Controls/ComboBox.cs b/src/Avalonia.Controls/ComboBox.cs index 6557346b1f..75a0e41e7b 100644 --- a/src/Avalonia.Controls/ComboBox.cs +++ b/src/Avalonia.Controls/ComboBox.cs @@ -7,6 +7,7 @@ using Avalonia.Controls.Shapes; using Avalonia.Controls.Templates; using Avalonia.Input; using Avalonia.Interactivity; +using Avalonia.Layout; using Avalonia.LogicalTree; using Avalonia.Media; using Avalonia.VisualTree; @@ -63,6 +64,18 @@ namespace Avalonia.Controls public static readonly StyledProperty PlaceholderForegroundProperty = AvaloniaProperty.Register(nameof(PlaceholderForeground)); + /// + /// Defines the property. + /// + public static readonly StyledProperty HorizontalContentAlignmentProperty = + ContentControl.HorizontalContentAlignmentProperty.AddOwner(); + + /// + /// Defines the property. + /// + public static readonly StyledProperty VerticalContentAlignmentProperty = + ContentControl.VerticalContentAlignmentProperty.AddOwner(); + private bool _isDropDownOpen; private Popup _popup; private object _selectionBoxItem; @@ -133,6 +146,24 @@ namespace Avalonia.Controls set { SetValue(VirtualizationModeProperty, value); } } + /// + /// Gets or sets the horizontal alignment of the content within the control. + /// + public HorizontalAlignment HorizontalContentAlignment + { + get { return GetValue(HorizontalContentAlignmentProperty); } + set { SetValue(HorizontalContentAlignmentProperty, value); } + } + + /// + /// Gets or sets the vertical alignment of the content within the control. + /// + public VerticalAlignment VerticalContentAlignment + { + get { return GetValue(VerticalContentAlignmentProperty); } + set { SetValue(VerticalContentAlignmentProperty, value); } + } + /// protected override IItemContainerGenerator CreateItemContainerGenerator() { diff --git a/src/Avalonia.Themes.Default/ComboBox.xaml b/src/Avalonia.Themes.Default/ComboBox.xaml index 95bd9550a5..c4b64d7e2c 100644 --- a/src/Avalonia.Themes.Default/ComboBox.xaml +++ b/src/Avalonia.Themes.Default/ComboBox.xaml @@ -1,10 +1,31 @@ + + + + + Item 1 + Item 2 + + + Item 1 + Item 2 + + + +