Browse Source

Update SelectionBoxItem on visual tree attach.

Fixes initial sizing of `SelectionBoxItem` when it's a control.
pull/5024/head
Steven Kirk 6 years ago
parent
commit
e17f18de45
  1. 32
      src/Avalonia.Controls/ComboBox.cs

32
src/Avalonia.Controls/ComboBox.cs

@ -173,11 +173,10 @@ namespace Avalonia.Controls
ComboBoxItem.ContentTemplateProperty);
}
/// <inheritdoc/>
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToLogicalTree(e);
this.UpdateSelectionBoxItem(this.SelectedItem);
base.OnAttachedToVisualTree(e);
this.UpdateSelectionBoxItem(SelectedItem);
}
/// <inheritdoc/>
@ -373,19 +372,22 @@ namespace Avalonia.Controls
if (control != null)
{
control.Measure(Size.Infinity);
SelectionBoxItem = new Rectangle
if (VisualRoot is object)
{
Width = control.DesiredSize.Width,
Height = control.DesiredSize.Height,
Fill = new VisualBrush
control.Measure(Size.Infinity);
SelectionBoxItem = new Rectangle
{
Visual = control,
Stretch = Stretch.None,
AlignmentX = AlignmentX.Left,
}
};
Width = control.DesiredSize.Width,
Height = control.DesiredSize.Height,
Fill = new VisualBrush
{
Visual = control,
Stretch = Stretch.None,
AlignmentX = AlignmentX.Left,
}
};
}
}
else
{

Loading…
Cancel
Save