Browse Source

Limit initial measure of virtualized list.

Prevents all items being materialized when virtualized control is
measured with infinity.
pull/576/head
Steven Kirk 10 years ago
parent
commit
d581bfe69e
  1. 20
      src/Avalonia.Controls/Presenters/ItemsPresenter.cs
  2. 2
      src/Avalonia.Controls/VirtualizingStackPanel.cs

20
src/Avalonia.Controls/Presenters/ItemsPresenter.cs

@ -91,6 +91,26 @@ namespace Avalonia.Controls.Presenters
_virtualizer?.ScrollIntoView(item);
}
protected override Size MeasureOverride(Size availableSize)
{
// If infinity is passed as the available size and we're virtualized then we need to
// fill the available space, but to do that we *don't* want to materialize all our
// items! Take a look at the root of the tree for a MaxClientSize and use that as
// the available size.
if (availableSize == Size.Infinity && VirtualizationMode != ItemVirtualizationMode.None)
{
var window = VisualRoot as Window;
if (window != null)
{
availableSize = window.PlatformImpl.MaxClientSize;
}
}
Panel.Measure(availableSize);
return Panel.DesiredSize;
}
/// <inheritdoc/>
protected override void PanelCreated(IPanel panel)
{

2
src/Avalonia.Controls/VirtualizingStackPanel.cs

@ -65,8 +65,6 @@ namespace Avalonia.Controls
{
if (availableSize != ((ILayoutable)this).PreviousMeasure)
{
// TODO: We need to put a reasonable limit on this, probably based on the max
// window size.
_availableSpace = availableSize;
Controller?.UpdateControls();
}

Loading…
Cancel
Save