protected override void OnAttached() { base.OnAttached(); AssociatedObject.AllowRecreateNodesOnEndDataUpdate = false; AssociatedObject.NodeExpanded += AssociatedObject_NodeExpanded; AssociatedObject.DataControl.CurrentItemChanged += DataControl_CurrentItemChanged; AssociatedObject.NodeExpanding += (s, e) => { e.Allow = !IsUpdating; }; AssociatedObject.NodeCollapsing += (s, e) => { e.Allow = !IsUpdating; }; DataControlReferences.Add(new WeakReference <DataControlBase>(AssociatedObject.DataControl)); }
private static void EndDataUpdate() { List <WeakReference <DataControlBase> > deadReferences = new List <WeakReference <DataControlBase> >(); foreach (WeakReference <DataControlBase> reference in DataControlReferences) { if (reference.TryGetTarget(out DataControlBase dataControl)) { dataControl.EndDataUpdate(); } else { deadReferences.Add(reference); } } if (deadReferences.Count > 0) { deadReferences.ForEach(x => DataControlReferences.Remove(x)); } IsUpdating = false; }