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.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs index f75184c686..c4571505ba 100644 --- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs @@ -95,6 +95,7 @@ namespace Avalonia.Controls.Presenters static ContentPresenter() { AffectsRender(BackgroundProperty, BorderBrushProperty, BorderThicknessProperty, CornerRadiusProperty); + AffectsArrange(HorizontalContentAlignmentProperty, VerticalContentAlignmentProperty); AffectsMeasure(BorderThicknessProperty, PaddingProperty); ContentProperty.Changed.AddClassHandler((x, e) => x.ContentChanged(e)); ContentTemplateProperty.Changed.AddClassHandler((x, e) => x.ContentChanged(e)); diff --git a/src/Avalonia.Themes.Default/ComboBox.xaml b/src/Avalonia.Themes.Default/ComboBox.xaml index 95bd9550a5..ae5b902ae8 100644 --- a/src/Avalonia.Themes.Default/ComboBox.xaml +++ b/src/Avalonia.Themes.Default/ComboBox.xaml @@ -1,10 +1,29 @@ + + + + + Item 1 + Item 2 + + + Item 1 + Item 2 + + + + - + + + - + - + - + - - - + - + - + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml b/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml index c26dec3d34..66ccea99b5 100644 --- a/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml +++ b/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml @@ -1,17 +1,19 @@ - - + + Item 1 - Item 2 - - - - Item 1 - Item 2 - - + Item 2 long + Item 3 + Item 4 + + @@ -19,12 +21,11 @@ - - + Padding="{TemplateBinding Padding}" /> + + + + + + + + - + -