0

I have a DockingManager ( Syncfusion.Windows.Forms.Tools.DockingManager ) containing an ElementHost (System.Windows.Forms.Integration.ElementHost). The child of the ElementHost is a custom WPF userControl (the elementHost sees it has a FrameworkElement).

I want to handle an event when the tab is opened. I tried many things (OnVisibilityChanged, IsHitTestVisibleChanged, DockVisibilityChanging, VisibleChanged). OnVisibilityChanged on the WPF userControl seemed to work but it seems that it is triggered only the first time the tab is opened.

I have done a lot of trial and error but nothing seems to work. I could use some help please.

cricardol
  • 4,212
  • 3
  • 20
  • 28
  • Does this answer your question? [WPF canvas VisibilityChanged event](https://stackoverflow.com/questions/6634976/wpf-canvas-visibilitychanged-event) – StayOnTarget Apr 12 '22 at 17:55

1 Answers1

2

I was tired of searching. I did the stupid but rapid thing:

          dockingManager.DockControlActivated += handler1;
          dockingManager.DockControlDeactivated += handler2;
          dockingManager.DockMenuClick += handler3;
          dockingManager.DockStateChanged+=handler4;
          dockingManager.DockStateChanging += handler5;
          dockingManager.DockVisibilityChanged += handler6;
          dockingManager.DockVisibilityChanging += handler7;
          dockingManager.NewDockStateBeginLoad += handler8;
          dockingManager.NewDockStateEndLoad += handler9;
          dockingManager.DockAllow += handler10;
          dockingManager.ControlRestored += handler11;
          dockingManager.ControlMinimized += handler12;
          dockingManager.ControlMaximizing += handler13;
          dockingManager.ControlMaximized += handler14;
          dockingManager.AutoHideAnimationStop += handler15;
          dockingManager.AutoHideAnimationStart += handler16;

}

private void handler16(object sender, AutoHideAnimationEventArgs arg)
{
  int i=0;i++;
}

private void handler15(object sender, AutoHideAnimationEventArgs arg)
{
  int i=0;i++;
}

private void handler14(object sender, ControlMaximizedEventArgs args)
{
  int i=0;i++;
}
...

I have put a breakpoint in each handler and I found out that AutoHideAnimationStop or AutoHideAnimationStart could do the trick. It is triggered even if I open the tab with code (ie: dockingManager.ActivateControl(ElementHost);). I can also look at the arg to see if it is rolledin or rolledout.

my solution:

 private void OnLoadCompleted( object _sender )  
 {
   dockingManager.AutoHideAnimationStop += handler15;

 }
 private void handler15(object _sender, AutoHideAnimationEventArgs _arg)
 {
   MyUserControl childControl = (MyUserControl )MyElementHost.Child;
   if ( MyElementHost!= null && childControl != null && MyElementHost.Visible )
   {
     childControl.OnVisibilityChanged(_sender, _arg);
   }
 }
cricardol
  • 4,212
  • 3
  • 20
  • 28