Technically this could be considered a breaking change if someone was depending on the old behavior, however the old behavior resulted in layouts that were not predictable to the user. So while yes someone could have built something that works, it would have been via trial and error and generally breaking the rule of one parent to each view. Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=39509
Assert.False (added);
Assert.False (removed);
}
+
+ [Test]
+ public void AddToSecondLayoutRemovesFromOriginal()
+ {
+ var child = new BoxView();
+ var layout1 = new NaiveLayout();
+ var layout2 = new NaiveLayout();
+
+ layout1.Children.Add(child);
+ layout2.Children.Add(child);
+
+ Assert.False(layout1.Children.Contains(child));
+ }
}
}
void OnInternalAdded(View view)
{
+ var parent = view.Parent as Layout;
+ parent?.InternalChildren.Remove(view);
+
OnChildAdded(view);
if (ShouldInvalidateOnChildAdded(view))
InvalidateLayout();