Skip to content

Commit

Permalink
LayoutRoot doesn't notify change for Children or ChildrenCount #1313
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirkster99 committed Feb 14, 2019
1 parent 5c22b1e commit d65e9a9
Showing 1 changed file with 66 additions and 13 deletions.
79 changes: 66 additions & 13 deletions source/Components/Xceed.Wpf.AvalonDock/Layout/LayoutRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,41 +771,75 @@ internal void OnLayoutElementRemoved( LayoutElement element )
ElementRemoved( this, new LayoutElementEventArgs( element ) );
}

#endregion
#endregion

#region Private Methods

private void _floatingWindows_CollectionChanged( object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e )
private void _floatingWindows_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if( e.OldItems != null && ( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace ) )
bool bNotifyChildren = false;

if (e.OldItems != null && (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace))
{
foreach( LayoutFloatingWindow element in e.OldItems )
foreach (LayoutFloatingWindow element in e.OldItems)
{
if( element.Parent == this )
if (element.Parent == this)
{
element.Parent = null;
bNotifyChildren = true;
}
}
}

if( e.NewItems != null && ( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace ) )
if (e.NewItems != null && (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace))
{
foreach( LayoutFloatingWindow element in e.NewItems )
foreach (LayoutFloatingWindow element in e.NewItems)
{
element.Parent = this;
bNotifyChildren = true;
}
}
}

// descendants of LayoutElement notify when their Children and ChildrenCount properties change
// https://github.com/xceedsoftware/wpftoolkit/issues/1313
//
if (bNotifyChildren == true &&
(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add
))
{
RaisePropertyChanged("Children");
RaisePropertyChanged("ChildrenCount");
}
else
{
if (bNotifyChildren == true &&
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
{
RaisePropertyChanged("Children");
}
}
}


private void _hiddenAnchorables_CollectionChanged( object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e )
{
bool bNotifyChildren = false;

if( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace )
{
if( e.OldItems != null )
{
foreach( LayoutAnchorable element in e.OldItems )
{
if( element.Parent == this )
if( element.Parent == this)
{
element.Parent = null;
bNotifyChildren = true;
}
}
}
}
Expand All @@ -821,15 +855,34 @@ private void _hiddenAnchorables_CollectionChanged( object sender, System.Collect
{
if( element.Parent != null )
element.Parent.RemoveChild( element );

element.Parent = this;
bNotifyChildren = true;
}

}
}
}



// descendants of LayoutElement notify when their Children and ChildrenCount properties change
// https://github.com/xceedsoftware/wpftoolkit/issues/1313
//
if (bNotifyChildren == true &&
(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add
))
{
RaisePropertyChanged("Children");
RaisePropertyChanged("ChildrenCount");
}
else
{
if (bNotifyChildren == true &&
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace )
{
RaisePropertyChanged("Children");
}
}
}

private void InternalSetActiveContent( LayoutContent currentValue, LayoutContent newActiveContent )
Expand Down

0 comments on commit d65e9a9

Please sign in to comment.