Articles in this section
Category / Section

How to restrict WPF DockingManager floatwindows are always top on parent window?

1 min read

When the window state is changed as float at runtime, the floatwindows will be the top of the mainwindow. Because WPF DockingManager, parent window will be the Owner for all FloatWindows. So, all the FloatWindows will be on Top of ParentWindow. We can restrict this behavior by setting Owner of NativeFloatwindow as null.  The same has been demonstrated in the following code.

MainWindow.Xaml

<syncfusion:DockingManager x:Name="Docking" UseNativeFloatWindow="True" DockStateChanged="DockingManager_DockStateChanged">
   <ContentControl x:Name="SolutionExplorer" syncfusion:DockingManager.Header="Solution  Explorer" />
   <ContentControl x:Name="ToolBox" syncfusion:DockingManager.Header="Toolbox"/>
   <ContentControl x:Name="Properties" syncfusion:DockingManager.Header="Properties"/>
   <ContentControl x:Name="Output" syncfusion:DockingManager.Header="Output"/>
   <ContentControl x:Name="StartPage" syncfusion:DockingManager.Header="Start Page" syncfusion:DockingManager.State="Dock" />
</syncfusion:DockingManager>

C#

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();         
    }
    DispatcherTimer timer = new DispatcherTimer();
    private void DockingManager_DockStateChanged(FrameworkElement sender, Syncfusion.Windows.Tools.Controls.DockStateEventArgs e)
    {
       if (e.NewState == DockState.Float)
       {
          timer.Interval = new TimeSpan(0, 0, 3);
          timer.Tick += timer_Tick;
          timer.Start();
       }           
    }
    void timer_Tick(object sender, EventArgs e)
    { 
        foreach(var window in Application.Current.Windows)
        {
           if(window is NativeFloatWindow)
           {
              NativeFloatWindow win = window as NativeFloatWindow;                   
              win.Owner = null;
           }
        }
        timer.Stop();
     }
}

 

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