Articles in this section
Category / Section

How to change the visibility of Float window as visible in WPF DockingManager?

2 mins read

While changing the selection in TabControl, TabItem content will be Collapsed other than selected tab. So FloatWindows will be visible only when the Parent TabItem is Selected. It is the default behavior of the TabControl.

We can overcome this behavior by changing the IsOpen property of the NativeFloatWindow as True. The same has been demonstrated in the following code.

MainWindow.xaml

       <syncfusion:TabControlExt IsDisableUnloadTabItemExtContent="True" 
                                 LayoutUpdated="TabControlExt_LayoutUpdated" >
            <syncfusion:TabItemExt Header=" Tab1">
                <local:UserControl_one />
            </syncfusion:TabItemExt>
            <syncfusion:TabItemExt Header=" Tab2">
                <local:UserControl_two  />
            </syncfusion:TabItemExt>
       </syncfusion:TabControlExt>

 

MainWindow.cs

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
 
        private void TabControlExt_LayoutUpdated(object sender, EventArgs e)
        {
            foreach (var window in Application.Current.Windows)
            {
                if (window is NativeFloatWindow)
                {
                    foreach (var content in FloatedCollection)
                    {
                        if (VisualUtils.FindRootVisual(content as Visual) == window)
                        {
                            NativeFloatWindow win = window as NativeFloatWindow;
                            win.IsOpen = true;
                        }
                    }
                    
                }
            }
        }
 
      public static ObservableCollection<DependencyObject> FloatedCollection = new 
                                      ObservableCollection<DependencyObject>();
    }

 

 

 

UserControl.xaml:

<syncfusion:DockingManager x:Name="dockingmanager_one" UseNativeFloatWindow="True" 
                           DockStateChanged="dockingmanager_one_DockStateChanged">
       <ContentControl x:Name="content" syncfusion:DockingManager.Header="Window"/>
</syncfusion:DockingManager>

 

UserControl.cs

    public partial class UserControl_one : UserControl
    {
        public UserControl_one()
        {
            InitializeComponent();
          
        }
 
        private void dockingmanager_one_DockStateChanged(FrameworkElement sender, 
                     Syncfusion.Windows.Tools.Controls.DockStateEventArgs e)
        {
            if (e.NewState == DockState.Float)
            {
                MainWindow.FloatedCollection.Add(sender);
            }
            else
                MainWindow.FloatedCollection.Remove(sender);
        }
 
    }

 

Output:

 

 

Float Window(“Window”) is the child of Tab1, but “Window” is visible even if the Tab1 is not selected.

 

Conclusion

I hope you enjoyed learning about how to change the visibility of Float window as visible WPF DockingManager.

You can refer to our WPF TabControl feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF TabControl 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