private DockingWindow CreateDockingWindow(object rootModel, DockSite siteTarget) { var view = _viewStrategy.GetView(rootModel, null, null); var presenter = rootModel as IPresenter; if (presenter != null) { if (_cache.ContainsKey(presenter)) { return(_cache[presenter]); } var initialDockDirection = Direction.Left; var metadata = view.GetDockingWindowMetadata(); DockingWindow dockingWindow = new DocumentWindow(siteTarget); if (metadata == null) { dockingWindow.SetBinding( DockingWindow.TitleProperty, new Binding { BindsDirectlyToSource = true, Source = presenter.DisplayName, Mode = BindingMode.OneWay }); } else { if (metadata.IsToolWindow) { var toolWindow = new ToolWindow(siteTarget); #region ToolWindow Property Bindings toolWindow.SetBinding( ToolWindow.CanRaftProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanRaftProperty), Mode = BindingMode.OneWay }); toolWindow.SetBinding( ToolWindow.CanAutoHideProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanAutoHideProperty), Mode = BindingMode.OneWay }); toolWindow.SetBinding( ToolWindow.CanBecomeDocumentProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanBecomeDocumentProperty), Mode = BindingMode.OneWay }); #endregion dockingWindow = toolWindow; } else { dockingWindow.Content = view; } #region DockingWindow Property Bindings dockingWindow.SetBinding( DockingWindow.TitleProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.TitleProperty), Mode = BindingMode.OneWay }); dockingWindow.SetBinding( DockingWindow.CanCloseProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanCloseProperty), Mode = BindingMode.OneWay }); dockingWindow.SetBinding( DockingWindow.CanDragProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanDragProperty), Mode = BindingMode.OneWay }); dockingWindow.SetBinding( DockingWindow.CanAttachProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanAttachProperty), Mode = BindingMode.OneWay }); dockingWindow.SetBinding( DockingWindow.CanDockLeftProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanDockLeftProperty), Mode = BindingMode.OneWay }); dockingWindow.SetBinding( DockingWindow.CanDockRightProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanDockRightProperty), Mode = BindingMode.OneWay }); dockingWindow.SetBinding( DockingWindow.CanDockTopProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanDockTopProperty), Mode = BindingMode.OneWay }); dockingWindow.SetBinding( DockingWindow.CanDockBottomProperty, new Binding { Source = metadata, Path = new PropertyPath(DockingWindowMetadata.CanDockBottomProperty), Mode = BindingMode.OneWay }); #endregion switch (metadata.DefaultDock) { case DockSiteDock.Left: initialDockDirection = Direction.Left; break; case DockSiteDock.Right: initialDockDirection = Direction.Right; break; case DockSiteDock.Top: initialDockDirection = Direction.Top; break; case DockSiteDock.Bottom: initialDockDirection = Direction.Bottom; break; case DockSiteDock.Content: initialDockDirection = Direction.Content; break; } if (dockingWindow is ToolWindow) { var dockTarget = GetDockTarget(siteTarget, initialDockDirection); if (metadata.Undock) { dockingWindow.Float(metadata.DefaultSize); } else { ((ToolWindow)dockingWindow).Dock(dockTarget, (metadata.CreateNewDockingGroup) && !dockTarget.Equals(siteTarget) ? Direction.Content : initialDockDirection); } } } _binder.Bind(rootModel, view, null); dockingWindow.Content = view; presenter.Initialize(); _cache[presenter] = dockingWindow; return(_cache[presenter]); } throw new Exception(Properties.Resources.NullRootModelException); }