)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WPF |
Control: DockingManager |
Published Date: November 14, 2016 |
Last Revised Date: November 14, 2016

This article describes how to find whether the side panel in 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 DockingManager by traversing visual tree and identify their sides with the help of PanelSide poperty.

SidePanel events

SidePanel class has the events Show and Hide, hook these event 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;

                }

            }

        }

 

The following screenshot illustrates the output:

Figure: Side panel item hovered to view the content

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon