Articles in this section
Category / Section

How to find whether AutoHidden element in WPF DockingManager is expanded or collapsed?

2 mins read

This article describes how to find whether the side panel in WPF DockingManager is expanded or collapsed. Follow the below steps to get notified when auto hidden content panel expands and collapses.

Retrieve SidePanels

Retrieve the SidePanels in WPF DockingManager by traversing visual tree and identify their sides with the help of PanelSide poperty.

SidePanel events

The SidePanel class has the events Show and Hide, hook these events for each side. Show event notifies user when the panel is being expanded and Hide event notifies user when the panel is being collapsed.

The following code example demonstrates the same.

XAML

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="60"/>
    <RowDefinition/>
  </Grid.RowDefinitions>
  <StackPanel Orientation="Vertical">
    <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
                <TextBlock Text="Panel Event: " Margin="5 0 0 0" FontSize="16"/>
                <TextBlock x:Name="showHideEventText" FontSize="16" Foreground="Green" FontStyle="Italic"/>
    </StackPanel>
  </StackPanel>
  <syncfusion:DockingManager Grid.Row="1" x:Name="dockingManager" DockFill="True" Loaded="dockingManager_Loaded">
    <ContentControl x:Name="left" syncfusion:DockingManager.Header="Left" syncfusion:DockingManager.SideInDockedMode="Left" syncfusion:DockingManager.State="AutoHidden" />            
  </syncfusion:DockingManager>      
</Grid>

C#

private void dockingManager_Loaded(object sender, RoutedEventArgs e)
{
  foreach (SidePanel panel in FindVisualChildrenOfType<SidePanel>(dockingManager))
  {
    if (panel.PanelSide == Dock.Left) 
    {
      panel.ShowEvent += Panel_ShowEvent;
      panel.HideEvent += Panel_HideEvent;
      break;
    }
  }
  dockingManager.Loaded -= dockingManager_Loaded;
}
 
private void Panel_HideEvent(object sender, RoutedEventArgs e)
{
  showHideEventText.Text = "Hide";
}
 
private void Panel_ShowEvent(object sender, RoutedEventArgs e)
{
  showHideEventText.Text = "Show";
}
 
public static IEnumerable<T> FindVisualChildrenOfType<T>(DependencyObject parent) where T : DependencyObject
{
  List<T> foundChildren = new List<T>();
  int childCount = VisualTreeHelper.GetChildrenCount(parent);
  for (int i = 0; i < childCount; i++)
  {
    var child = VisualTreeHelper.GetChild(parent, i);
    T childType = child as T;
    if (childType == null)
    {
      foreach (var other in FindVisualChildrenOfType<T>(child))
        yield return other;
    }
    else
    {
      yield return (T)child;
    }
  }
}

 

Side panel item hovered to view the content in WPF DockingManager


Conclusion

I hope you enjoyed learning about how to find whether the AutoHidden element in WPF DockingManager is expanded or collapsed.

You can refer to our  WPF DockingManager feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF DockingManage documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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