private void CreateChildrenViews() { var manager = _model.Root.Manager; foreach (var childModel in _model.Children) { var lac = new LayoutAnchorControl(childModel); lac.SetBinding(LayoutAnchorControl.TemplateProperty, new Binding(DockingManager.AnchorTemplateProperty.Name) { Source = manager }); _childViews.Add(lac); } }
private void OnModelChildrenCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove || e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace) { if (e.OldItems != null) { { foreach (var childModel in e.OldItems) { _childViews.Remove(_childViews.First(cv => cv.Model == childModel)); } } } } if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset) { _childViews.Clear(); } if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add || e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace) { if (e.NewItems != null) { var manager = _model.Root.Manager; int insertIndex = e.NewStartingIndex; foreach (LayoutAnchorable childModel in e.NewItems) { var lac = new LayoutAnchorControl(childModel); lac.SetBinding(LayoutAnchorControl.TemplateProperty, new Binding(DockingManager.AnchorTemplateProperty.Name) { Source = manager }); _childViews.Insert(insertIndex++, lac); } } } }