/// <summary>
        /// Shows a docking window for a given view.  
        /// If is has been shown before, restore it position. Otherwise dock it to the right side.
        /// </summary>
        /// <param name="view">View to dock.</param>
        /// <param name="dockingStyle">Docking style.</param>
        /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
        public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle)
        {
            // init resource dictionaries for plugin hosters
            if (view is IPluginHosterViewModel)
            {
                IPluginHosterViewModel pHost = (IPluginHosterViewModel)view;
                if (pHost.IsVMPlugin)
                {
                    if (!pHost.VMPluginDictionaryInitialized)
                        try
                        {
                            if (pHost.VMPlugin.GetViewModelRessourceDictionary() != null)
                                if (System.Windows.Application.Current != null)
                                {
                                    System.Windows.Application.Current.Resources.BeginInit();
                                    System.Windows.Application.Current.Resources.MergedDictionaries.Add(pHost.VMPlugin.GetViewModelRessourceDictionary());
                                    System.Windows.Application.Current.Resources.EndInit();
                                }
                            pHost.VMPluginDictionaryInitialized = true;
                        }
                        catch
                        {
                            pHost.VMPluginDictionaryInitialized = false;
                        }
                }
            }
            if (!this.isRestoringLayout)
            {
                if (!view.IsInitialized)
                    view.InitializeVM();

                if (view is IRibbonDockableViewModel && this.Ribbon != null)
                    if (!((IRibbonDockableViewModel)view).IsRibbonMenuInitialized)
                    {
                        ((IRibbonDockableViewModel)view).CreateRibbonMenu(this.Ribbon);
                    }
            }

            if (!viewLookup.ContainsKey(view.DockingPaneName))
            {
                DockableContent content = new DockableContent();
                content.Name = view.DockingPaneName;
                content.Title = view.DockingPaneTitle;
                content.Content = view;
                content.StateChanged += new System.Windows.RoutedEventHandler(content_StateChanged);
                if (view.ActivationMode == ActivationMode.Normal)
                    content.IsActiveContentChanged += new EventHandler(content_IsActiveContentChanged);
                content.ContextChangeKind = ConvertToContextChangeKind(view.DockingContextChangeKind);

                viewLookup.Add(view.DockingPaneName, new ViewLookUp(view, content));
                
                if (this.isRestoringLayout)
                {
                    this.MainDockingManager.AddPaneForLayoutRestore(content);
                }
                else
                {
                    if (dockingStyle == DockingPaneStyle.Floating)
                    {
                        content.FloatingWindowSize = new Size(view.FloatingWindowDesiredWidth, view.FloatingWindowDesiredHeight);
                        content.ShowAsFloatingWindow(this.MainDockingManager, true);
                    }
                    else if (dockingStyle == DockingPaneStyle.DockedInDocumentPane)
                        content.ShowAsDocument(this.MainDockingManager);
                    else
                    {
                        if (view.DockedWindowDesiredWidth > 0)
                            content.DesiredWidth = view.DockedWindowDesiredWidth;
                        if (view.DockedWindowDesiredHeight > 0)
                            content.DesiredHeight = view.DockedWindowDesiredHeight;

                        AnchorStyle style = ConvertToAnchorStyle(dockingAnchorStyle);
                        if (style != AnchorStyle.None)
                        {
                            content.Show(this.MainDockingManager, style);
                        }
                        else
                            content.Show(this.MainDockingManager);
                    }
                }
            }

            // show docking window
            if (!this.isRestoringLayout)
            if (!viewLookup[view.DockingPaneName].Pane.IsVisible)
            {
                if (dockingStyle == DockingPaneStyle.Floating)
                {
                    viewLookup[view.DockingPaneName].Pane.FloatingWindowSize = new Size(view.FloatingWindowDesiredWidth, view.FloatingWindowDesiredHeight);
                    viewLookup[view.DockingPaneName].Pane.ShowAsFloatingWindow(this.MainDockingManager, true);
                }
                else if (dockingStyle == DockingPaneStyle.DockedInDocumentPane)
                    viewLookup[view.DockingPaneName].Pane.ShowAsDocument(this.MainDockingManager);
                else
                    viewLookup[view.DockingPaneName].Pane.Show(this.MainDockingManager);

                view.IsDockingPaneVisible = true;
            }
        }
 private void BindAndShow(DockableContent view, object viewModel)
 {
     view.DataContext = ForView.Wrap(viewModel);
     view.ShowAsDocument(dockManager);
     view.Focus();
 }
        void BuildDockingLayout()
        {
            dockManager.Content = null;

            //TreeView dockable content
            var trv = new TreeView();
            trv.Items.Add(new TreeViewItem() { Header = "Item1" });
            trv.Items.Add(new TreeViewItem() { Header = "Item2" });
            trv.Items.Add(new TreeViewItem() { Header = "Item3" });
            trv.Items.Add(new TreeViewItem() { Header = "Item4" });
            ((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem1" });
            ((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem2" });
            ((TreeViewItem)trv.Items[1]).Items.Add(new TreeViewItem() { Header = "SubItem3" });
            ((TreeViewItem)trv.Items[2]).Items.Add(new TreeViewItem() { Header = "SubItem4" });
            var treeviewContent = new DockableContent() { Title = "Explorer", Content = trv };

            treeviewContent.Show(dockManager, AnchorStyle.Left);

            //TextBox invo dockable content
            var treeviewInfoContent = new DockableContent() { Title = "Explorer Info", Content = new TextBox() { Text = "Explorer Info Text", IsReadOnly = true } };
            treeviewContent.ContainerPane.Items.Add(treeviewInfoContent);


            //ListView dockable content
            var gridView = new GridView();
            gridView.Columns.Add(new GridViewColumn() { Header = "Date" });
            gridView.Columns.Add(new GridViewColumn() { Header = "Day Of Weeek", DisplayMemberBinding = new Binding("DayOfWeek") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Year", DisplayMemberBinding = new Binding("Year") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Month", DisplayMemberBinding = new Binding("Month") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Second", DisplayMemberBinding = new Binding("Second") });
            var listView = new ListView() { View = gridView };
            listView.Items.Add(DateTime.Now);
            listView.Items.Add(DateTime.Now.AddYears(-1));
            listView.Items.Add(DateTime.Now.AddMonths(15));
            listView.Items.Add(DateTime.Now.AddHours(354));

            var listViewContent = new DockableContent() { Title = "Date & Times", Content = listView };
            listViewContent.ShowAsFloatingWindow(dockManager, true);

            //TextBox dockable content
            var textboxSampleContent = new DockableContent() { Title = "Date & Times Info", Content = new TextBox() { Text = "Date & Times Info Text", IsReadOnly = true } };
            listViewContent.ContainerPane.Items.Add(textboxSampleContent);


            //DataGrid document
            var dataGrid = new DataGrid();
            var rnd = new Random();
            var data = new List<Tuple<double, double, double, double>>();
            for (int i = 0; i < 100; i++)
            {
                data.Add(Tuple.Create(rnd.NextDouble(), rnd.NextDouble() * 10.0, rnd.NextDouble() * 100.0, rnd.NextDouble() * 1000.0));
            }

            dataGrid.ItemsSource = data;

            var dataGridDocument = new DocumentContent() { Title = "Data", IsLocked = true, Content = dataGrid };
            dataGridDocument.Show(dockManager);

            //DataGrid Info Text sample
            var dataGridInfoContent = new DockableContent() { Title = "Data Info", Content = new TextBox() { Text = "Data Info Text" } };
            dataGridInfoContent.ShowAsDocument(dockManager);

        }