Browse Source

Extend the fix for Recycling the focused element to non virtualized l…

…ayouts

* Ensure that we set the m_processingItesmSourceChange flag for non-virtualizing layouts as well as virtualizing ones.

Ported from cc335ac391
pull/3424/head
Steven Kirk 7 years ago
parent
commit
bb7276d568
  1. 36
      src/Avalonia.Controls/Repeater/ItemsRepeater.cs

36
src/Avalonia.Controls/Repeater/ItemsRepeater.cs

@ -562,34 +562,34 @@ namespace Avalonia.Controls
if (Layout != null) if (Layout != null)
{ {
if (Layout is VirtualizingLayout virtualLayout) var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
{
var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
try
{
_processingItemsSourceChange = args; _processingItemsSourceChange = args;
try if (Layout is VirtualizingLayout virtualLayout)
{ {
virtualLayout.OnItemsChanged(GetLayoutContext(), newValue, args); virtualLayout.OnItemsChanged(GetLayoutContext(), newValue, args);
} }
finally else if (Layout is NonVirtualizingLayout nonVirtualLayout)
{ {
_processingItemsSourceChange = null; // Walk through all the elements and make sure they are cleared for
} // non-virtualizing layouts.
} foreach (var element in Children)
else if (Layout is NonVirtualizingLayout nonVirtualLayout)
{
// Walk through all the elements and make sure they are cleared for
// non-virtualizing layouts.
foreach (var element in Children)
{
if (GetVirtualizationInfo(element).IsRealized)
{ {
ClearElementImpl(element); if (GetVirtualizationInfo(element).IsRealized)
{
ClearElementImpl(element);
}
} }
}
Children.Clear(); Children.Clear();
}
}
finally
{
_processingItemsSourceChange = null;
} }
InvalidateMeasure(); InvalidateMeasure();

Loading…
Cancel
Save