private static void OnItemSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DockingAdapter instance = (DockingAdapter)d; if (instance != null) { if (e.OldValue != null) { var oldcollection = e.OldValue as INotifyCollectionChanged; oldcollection.CollectionChanged -= instance.CollectionChanged; } if (e.NewValue != null) { var newcollection = e.NewValue as INotifyCollectionChanged; foreach (var item in ((IList)e.NewValue)) { if (item is IChildrenElement) { instance.CreateChildren(item as IChildrenElement, instance); } } newcollection.CollectionChanged += instance.CollectionChanged; } } }
private void CreateChildren(IChildrenElement element, DockingAdapter adapter) { ContentControl control = new ContentControl() { Content = element }; control.Name = element.Name; adapter.SetCanAutoHide(control as DependencyObject, element); adapter.SetCanClose(control as DependencyObject, element); adapter.SetCanDock(control as DependencyObject, element); adapter.SetCanDocument(control as DependencyObject, element); adapter.SetCanDrag(control as DependencyObject, element); adapter.SetCanFloat(control as DependencyObject, element); adapter.SetDesiredHeightInDockedMode(control as DependencyObject, element); adapter.SetDesiredWidthInDockedMode(control as DependencyObject, element); adapter.SetDockAbility(control as DependencyObject, element); adapter.SetDockToFill(control as DependencyObject, element); adapter.SetHeader(control as DependencyObject, element); adapter.SetNoDock(control as DependencyObject, element); adapter.SetNoHeader(control as DependencyObject, element); adapter.SetSideInDockedMode(control as DependencyObject, element); adapter.SetSideInFloatMode(control as DependencyObject, element); adapter.SetState(control as DependencyObject, element); adapter.SetTargetNameInDockedMode(control as DependencyObject, element); adapter.SetTargetNameInFloatMode(control as DependencyObject, element); adapter.PART_DockingManager.Children.Add(control); }
private static void OnUseDocumentContainerChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { DockingAdapter adapter = sender as DockingAdapter; if (adapter != null) { adapter.PART_DockingManager.UseDocumentContainer = (bool)args.NewValue; } }
private static void OnActiveDocumentChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { DockingAdapter adapter = sender as DockingAdapter; if (adapter != null) { foreach (FrameworkElement element in adapter.PART_DockingManager.Children) { if (element is ContentControl) { ContentControl control = element as ContentControl; if (control != null && control.Content == args.NewValue) { adapter.PART_DockingManager.ActiveWindow = control; break; } } } } }