Articles in this section
Category / Section

How to restrict float window minimizing when the MainWindow get minimized in WPF DockingManager?

1 min read

As per the behavior of WPF DockingManager, the float window gets minimize while the main window of an application gets minimized. Since the owner of all float window of DockingManager is set as parent window.

To restrict this behavior, the owner of float window is set as null by getting all NativeFloatWindow in a current application. The same has been demonstrated below code example:

XAML

<Grid>
     <syncfusion:DockingManager Name="docking" UseNativeFloatWindow="True" UseDocumentContainer="True">
         <ContentControl syncfusion:DockingManager.Header="Dock Window 1" syncfusion:DockingManager.State="Dock"/>
         <ContentControl syncfusion:DockingManager.Header="Dock Window 2" syncfusion:DockingManager.State="Dock"/>
         <ContentControl syncfusion:DockingManager.Header="Dock Window 3" syncfusion:DockingManager.State="Dock"/>
         <ContentControl syncfusion:DockingManager.Header="Dock Window 1" syncfusion:DockingManager.State="Dock"/>
         <ContentControl syncfusion:DockingManager.Header="Dock Window 2" syncfusion:DockingManager.State="Dock"/>
         <ContentControl syncfusion:DockingManager.Header="Dock Window 3" syncfusion:DockingManager.State="Dock"/>
     </syncfusion:DockingManager>
</Grid>

C#

using System.Windows.Threading;
namespace WpfApplication3
{
  /// <summary>
  /// Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      docking.DockStateChanged += docking_DockStateChanged;
      timer.Interval = new TimeSpan(0, 0, 1);
      timer.Tick += timer_Tick;
      timer.Start();
      Closing += MainWindow_Closing;
    }
    void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
      timer.Stop();
    }
    void timer_Tick(object sender, EventArgs e)
    {
      if (StateChanged)
      {
        // Getting all native float window in an current application
        foreach (Window win in Application.Current.Windows)
        {
          if (win is NativeFloatWindow)
            win.Owner = null;
        }
        StateChanged = false;
      }
    }
    DispatcherTimer timer = new DispatcherTimer();
    bool StateChanged =false;
    void docking_DockStateChanged(FrameworkElement sender, DockStateEventArgs e)
    {
      StateChanged = true;
    }
  }
}

 

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