protected override void OnAttach()
        {
            _parentDockManager = XamDockManager.GetDockManager(_hostControl);
            if (_parentDockManager != null)
            {
                _parentDockManager.ActivePaneChanged += DockManager_ActivePaneChanged;
            }

            Region.ActiveViews.CollectionChanged += ActiveViews_CollectionChanged;
        }
        ContentPane GetContentPaneFromFromViewModel(object viewModel)
        {
            var panes = XamDockManager.GetDockManager(_hostControl).GetPanes(PaneNavigationOrder.VisibleOrder);

            foreach (ContentPane contentPane in panes)
            {
                if (contentPane.DataContext == viewModel)
                {
                    return(contentPane);
                }
            }

            return(null);
        }
Пример #3
0
        private ContentPane GetSiblingDocument()
        {
            DocumentContentHost dch = _target as DocumentContentHost;

            if (dch == null)
            {
                return(null);
            }

            if (null != dch.ActiveDocument)
            {
                return(dch.ActiveDocument);
            }

            XamDockManager dm = XamDockManager.GetDockManager(dch);

            if (dm == null)
            {
                return(null);
            }

            ContentPane firstDocument = null;

            foreach (ContentPane cp in dm.GetPanes(PaneNavigationOrder.VisibleOrder))
            {
                if (cp.PaneLocation != PaneLocation.Document)
                {
                    continue;
                }

                if (firstDocument == null)
                {
                    firstDocument = cp;
                }

                if (cp.Visibility != Visibility.Visible)
                {
                    continue;
                }

                return(cp);
            }

            return(firstDocument);
        }
Пример #4
0
        private void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, TabGroupPane regionTarget)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                //we want to add them behind any previous views that may have been manually declare in XAML or injected
                int startIndex = e.NewStartingIndex;
                foreach (object newItem in e.NewItems)
                {
                    ContentPane contentPane = PrepareContainerForItem(newItem, region);

                    if (regionTarget.Items.Count != startIndex)
                    {
                        startIndex = 0;
                    }

                    //we must make sure we bring the TabGroupPane into view.  If we don't a System.StackOverflowException will occur in
                    //UIAutomationProvider.dll if trying to add a ContentPane to a TabGroupPane that is not in view.
                    //This is most common when using nested TabGroupPane regions. If you don't this, you can comment it out.
                    regionTarget.BringIntoView();

                    regionTarget.Items.Insert(startIndex, contentPane);
                    regionTarget.Items.MoveCurrentTo(contentPane);
                    regionTarget.SelectedIndex = startIndex;
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                if (regionTarget.Items.Count == 0)
                {
                    return;
                }

                IEnumerable <ContentPane> contentPanes = XamDockManager.GetDockManager(regionTarget).GetPanes(PaneNavigationOrder.VisibleOrder);
                foreach (ContentPane contentPane in contentPanes)
                {
                    if (e.OldItems.Contains(contentPane) || e.OldItems.Contains(contentPane.Content))
                    {
                        contentPane.ExecuteCommand(ContentPaneCommands.Close);
                    }
                }
            }
        }
Пример #5
0
        ContentPane GetContentPaneFromFromViewModel(object viewModel)
        {
            var panes = XamDockManager.GetDockManager(_hostControl).GetPanes(PaneNavigationOrder.VisibleOrder);

            return(panes.FirstOrDefault(contentPane => contentPane.DataContext == viewModel));
        }