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

Loading…
Cancel
Save