Usually, when you use docking manager you want to be able to re-open the closed panes. This looks as simple as setting the IsHidden property of the pane to False. However, this does not cover all the cases. The pane might be in a ToolWindow and this ToolWindow might be closed by its X button. In this case, the pane would not be hidden, but it would not be visible either as it is in the hidden window.

Another approach might be closing the last pane in a ToolWindow, thus triggering closing the window, too. In this case the pane will be hidden, but setting the IsHidden property to false will not show the pane as it will still be in the hidden window.

For these two cases you will need to add some extra code. Below is a static method that accomplishes the task for you:

static void ShowPane(RadPane pane)
{
 if (pane.IsHidden)
    {
        pane.IsHidden = false;
    }
 
    var parentWindow = pane.ParentOfType<Telerik.Windows.Controls.Docking.ToolWindow>();
 if (parentWindow != null && parentWindow.Visibility == Visibility.Collapsed)
    {
 bool isDockable = pane.IsDockable;
 
 if (!isDockable)
        {
            pane.MakeFloatingDockable();
        }
 
        pane.MakeFloatingOnly();
 
 if (isDockable)
        {
            pane.MakeFloatingDockable();
        }
    }
}

Now, to demonstrate how to use this method, we will extend the example from the previous post. First, you need to name all the panes to have references to them. After that, you will add an extra menu item to the menu:

<telerikNavigation:RadMenuItem Header="Open">
 <telerikNavigation:RadMenuItem Header="Cities" Click="RadMenuItemOpenCities_Click" />
 <telerikNavigation:RadMenuItem Header="Main view" Click="RadMenuItemOpenMainView_Click" />
 <telerikNavigation:RadMenuItem Header="Morning" Click="RadMenuItemOpenMorning_Click" />
 <telerikNavigation:RadMenuItem Header="Noon" Click="RadMenuItemOpenNoon_Click" />
 <telerikNavigation:RadMenuItem Header="Evening" Click="RadMenuItemOpenEvening_Click" />
</telerikNavigation:RadMenuItem>

Then, you can implement the event handlers:

private void RadMenuItemOpenCities_Click(object sender, RoutedEventArgs e)
{
    ShowPane(this.Cities);
}
 
private void RadMenuItemOpenMainView_Click(object sender, RoutedEventArgs e)
{
    ShowPane(this.MainView);
}
 
private void RadMenuItemOpenMorning_Click(object sender, RoutedEventArgs e)
{
    ShowPane(this.Morning);
}
 
private void RadMenuItemOpenNoon_Click(object sender, RoutedEventArgs e)
{
    ShowPane(this.Noon);
}
 
private void RadMenuItemOpenEvening_Click(object sender, RoutedEventArgs e)
{
    ShowPane(this.Evening);
}
 

You can find the code here.


Related Posts

Comments

Comments are disabled in preview mode.