Răsfoiți Sursa

Add to logical children before notifying presenter.

This makes sure that newly added control items have the correct logical parent.
Steven Kirk 6 ani în urmă
părinte
comite
68b655b517
1 a modificat fișierele cu 2 adăugiri și 1 ștergeri
  1. 2 1
      src/Avalonia.Controls/ItemsControl.cs

+ 2 - 1
src/Avalonia.Controls/ItemsControl.cs

@@ -377,7 +377,6 @@ namespace Avalonia.Controls
         protected virtual void ItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
         {
             UpdateItemCount();
-            Presenter?.ItemsChanged(e);
 
             switch (e.Action)
             {
@@ -390,6 +389,8 @@ namespace Avalonia.Controls
                     break;
             }
 
+            Presenter?.ItemsChanged(e);
+
             var collection = sender as ICollection;
             PseudoClasses.Set(":empty", collection == null || collection.Count == 0);
             PseudoClasses.Set(":singleitem", collection != null && collection.Count == 1);