/// <summary>
 /// Sets the value of the <see cref="IsManagedProperty"/> attached property to a specified <see cref="DockSite"/>.
 /// </summary>
 /// <param name="obj">The object to which the attached property is written.</param>
 /// <param name="value">
 /// A value indicating whether the specified <see cref="DockSite"/> is being managed.
 /// </param>
 public static void SetIsManaged(DockSite obj, bool value)
 {
     if (null == obj)
     {
         throw new ArgumentNullException("obj");
     }
     obj.SetValue(DockSiteViewModelBehavior.IsManagedProperty, value);
 }
        /// <summary>
        /// Handles the <c>WindowRegistered</c> event of the <c>DockSite</c> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DockingWindowEventArgs"/> instance containing the event data.</param>
        private static void OnDockSiteWindowRegistered(object sender, DockingWindowEventArgs e)
        {
            DockSite dockSite = sender as DockSite;

            if (dockSite == null)
            {
                return;
            }

            // Ensure the DockingWindow exists and is generated for an item
            DockingWindow dockingWindow = e.Window;

            if (dockingWindow == null || !dockingWindow.IsContainerForItem)
            {
                return;
            }

            // Pass down the name, if any as this cannot be done via a Style
            if (string.IsNullOrEmpty(dockingWindow.Name))
            {
                var viewModel = dockingWindow.DataContext as ToolItemViewModel;
                if (viewModel != null && !string.IsNullOrEmpty(viewModel.Name))
                {
                    dockingWindow.Name = viewModel.Name;
                }
            }

            // Open the DockingWindow, if it's not already open
            if (!dockingWindow.IsOpen)
            {
                if (!dockSite.IsLoaded)
                {
                    // Need to delay the opening until after the DockSite is loaded because it's content will not be loaded
                    IList <DockingWindow> windowsPendingOpen = dockSite.GetValue(WindowsPendingOpenProperty) as IList <DockingWindow>;
                    if (windowsPendingOpen == null)
                    {
                        windowsPendingOpen = new List <DockingWindow>();
                        dockSite.SetValue(WindowsPendingOpenProperty, windowsPendingOpen);
                    }

                    windowsPendingOpen.Add(dockingWindow);
                }
                else
                {
                    OpenDockingWindow(dockSite, dockingWindow);
                }
            }
        }
 /// <summary>
 /// Sets the value of the <see cref="IsManagedProperty"/> attached property to a specified <see cref="DockSite"/>.
 /// </summary>
 /// <param name="obj">The object to which the attached property is written.</param>
 /// <param name="value">
 /// A value indicating whether the specified <see cref="DockSite"/> is being managed.
 /// </param>
 public static void SetIsManaged(DockSite obj, bool value)
 {
     if (null == obj) throw new ArgumentNullException("obj");
     obj.SetValue(DockSiteViewModelBehavior.IsManagedProperty, value);
 }