捕获OnVisibilityChanged事件

时间:2014-11-24 14:27:50

标签: c# .net wpf syncfusion

我有一个包含ElementHost(System.Windows.Forms.Integration.ElementHost)的DockingManager(Syncfusion.Windows.Forms.Tools.DockingManager)。 ElementHost的子节点是一个自定义的WPF userControl(elementHost看到它有一个FrameworkElement)。

我想在打开标签时处理事件。我尝试了很多东西(OnVisibilityChanged,IsHitTestVisibleChanged,DockVisibilityChanging,VisibleChanged)。 WPF userControl上的OnVisibilityChanged似乎可以工作,但它似乎只在第一次打开选项卡时触发。

我做了很多试验和错误,但似乎没有任何效果。我可以帮忙。

1 个答案:

答案 0 :(得分:1)

我厌倦了搜索。我做了愚蠢但很快的事情:

          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++;
}
...

我在每个处理程序中都放了一个断点,我发现AutoHideAnimationStop或AutoHideAnimationStart可以解决问题。即使我用代码打开选项卡(即:dockingManager.ActivateControl(ElementHost);)也会触发它。我也可以查看arg以查看它是否已滚动或滚动。

我的解决方案:

 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);
   }
 }