Skip to content

Commit

Permalink
Extend the fix for Recycling the focused element to non virtualized l…
Browse files Browse the repository at this point in the history
…ayouts

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

Ported from microsoft/microsoft-ui-xaml@cc335ac
  • Loading branch information
grokys committed Jan 9, 2020
1 parent 09297db commit bb7276d
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/Avalonia.Controls/Repeater/ItemsRepeater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,34 +562,34 @@ private void OnDataSourcePropertyChanged(ItemsSourceView oldValue, ItemsSourceVi

if (Layout != null)
{
if (Layout is VirtualizingLayout virtualLayout)
{
var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);

try
{
_processingItemsSourceChange = args;

try
if (Layout is VirtualizingLayout virtualLayout)
{
virtualLayout.OnItemsChanged(GetLayoutContext(), newValue, args);
}
finally
else if (Layout is NonVirtualizingLayout nonVirtualLayout)
{
_processingItemsSourceChange = null;
}
}
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)
// Walk through all the elements and make sure they are cleared for
// non-virtualizing layouts.
foreach (var element in Children)
{
ClearElementImpl(element);
if (GetVirtualizationInfo(element).IsRealized)
{
ClearElementImpl(element);
}
}
}

Children.Clear();
Children.Clear();
}
}
finally
{
_processingItemsSourceChange = null;
}

InvalidateMeasure();
Expand Down

0 comments on commit bb7276d

Please sign in to comment.