Articles in this section
Category / Section

How to programmatically open and close the auto-hidden child on mouse hover the SidePanel in WPF DockingManager?

1 min read

As per the behavior of WPF DockingManager, the autohide child will open and close on MouseHover the SideTabItem. But to open and close the autohide child on hovering anywhere on its SidePanel, invoke the method AutoHideTab and SelectTab of DockingManager in the left SidePanel MouseEnter and MouseLeave events, where the panel need to get retrieve using VisualUtils. The same has been demonstrated using the following code example:

XAML

<Window x:Class="DockingSidePanelOnHover.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
                 Title="MainWindow" Height="350" Width="525">
     <Grid>
          <syncfusion:DockingManager x:Name="DockingManager1">
              <ContentControl x:Name="Content1" syncfusion:DockingManager.Header="DockingManager1"></ContentControl>
          </syncfusion:DockingManager>
      </Grid>
</Window>

C#

using Syncfusion.Windows.Shared;
using Syncfusion.Windows.Tools.Controls;
namespace DockingSidePanelOnHover
{
   /// <summary>
   /// Interaction logic for MainWindow.xaml
   /// </summary>
   public partial class MainWindow : Window
   {
      public MainWindow()
      {
         InitializeComponent();
         DockingManager1.Loaded += DockingManager1_Loaded;
      }
      void DockingManager1_Loaded(object sender, RoutedEventArgs e)
      {
        foreach (SidePanel panel in VisualUtils.EnumChildrenOfType(DockingManager1, typeof(SidePanel)))
        {
           if (panel.Name == "PART_LeftPanel")
           {
             panel.MouseEnter += panel_MouseEnter;
             panel.MouseLeave += panel_MouseLeave;
             break;
           }
        }
      }
      private void panel_MouseLeave(object sender, MouseEventArgs e)
      {
         if (DockingManager.GetState(Content1) == DockState.AutoHidden)
         {
            DockingManager.AutoHideTab(Content1);
         }
      }
      private void panel_MouseEnter(object sender, MouseEventArgs e)
      {
         if (DockingManager.GetState(Content1) == DockState.AutoHidden)
         {
            DockingManager.SelectTab(Content1);
         }
      }
   }
}

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied