|
|
|
@ -1,8 +1,8 @@ |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Specialized; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Linq; |
|
|
|
using Avalonia.Animation; |
|
|
|
using Avalonia.Collections; |
|
|
|
using Avalonia.Controls; |
|
|
|
@ -479,16 +479,16 @@ namespace Avalonia |
|
|
|
switch (e.Action) |
|
|
|
{ |
|
|
|
case NotifyCollectionChangedAction.Add: |
|
|
|
SetLogicalParent(e.NewItems.Cast<ILogical>()); |
|
|
|
SetLogicalParent(e.NewItems); |
|
|
|
break; |
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Remove: |
|
|
|
ClearLogicalParent(e.OldItems.Cast<ILogical>()); |
|
|
|
ClearLogicalParent(e.OldItems); |
|
|
|
break; |
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Replace: |
|
|
|
ClearLogicalParent(e.OldItems.Cast<ILogical>()); |
|
|
|
SetLogicalParent(e.NewItems.Cast<ILogical>()); |
|
|
|
ClearLogicalParent(e.OldItems); |
|
|
|
SetLogicalParent(e.NewItems); |
|
|
|
break; |
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Reset: |
|
|
|
@ -702,13 +702,32 @@ namespace Avalonia |
|
|
|
OnDataContextChanged(EventArgs.Empty); |
|
|
|
} |
|
|
|
|
|
|
|
private void SetLogicalParent(IEnumerable<ILogical> children) |
|
|
|
private void SetLogicalParent(IList children) |
|
|
|
{ |
|
|
|
foreach (var i in children) |
|
|
|
var count = children.Count; |
|
|
|
|
|
|
|
for (var i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
var logical = (ILogical) children[i]; |
|
|
|
|
|
|
|
if (logical.LogicalParent is null) |
|
|
|
{ |
|
|
|
((ISetLogicalParent)logical).SetParent(this); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void ClearLogicalParent(IList children) |
|
|
|
{ |
|
|
|
var count = children.Count; |
|
|
|
|
|
|
|
for (var i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
if (i.LogicalParent == null) |
|
|
|
var logical = (ILogical) children[i]; |
|
|
|
|
|
|
|
if (logical.LogicalParent == this) |
|
|
|
{ |
|
|
|
((ISetLogicalParent)i).SetParent(this); |
|
|
|
((ISetLogicalParent)logical).SetParent(null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -784,17 +803,6 @@ namespace Avalonia |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void ClearLogicalParent(IEnumerable<ILogical> children) |
|
|
|
{ |
|
|
|
foreach (var i in children) |
|
|
|
{ |
|
|
|
if (i.LogicalParent == this) |
|
|
|
{ |
|
|
|
((ISetLogicalParent)i).SetParent(null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void NotifyResourcesChanged( |
|
|
|
ResourcesChangedEventArgs? e = null, |
|
|
|
bool propagate = true) |
|
|
|
|