2010-09-09 24 views
0

Essayer d'inclure un hoverIntent basé sur le code suivant:Comment puis-je mettre un XAML.CS timer qui agit comme HoverIntent en Javascript

private void ViewerTab_MouseLeave(object sender, MouseEventArgs e) 
      { 
       _mouseOverTabPanel = false; 

       ChangeCurrentPanelPosition(TabPanelPosition.Bottom); 
      } 

      private void ViewerTab_MouseEnter(object sender, MouseEventArgs e) 
      { 
       _mouseOverTabPanel = true; 
      } 

Le ChangeCurrentPanelPosition devrait idéalement que le feu après mouseleave pour ~ 1 sec et la La minuterie disparaîtra si mouseEnter est à nouveau activé.

+0

WPF? Windows Forms? Silverlight? Qu'avez-vous déjà essayé? Qu'est-il arrivé quand vous l'avez essayé? –

+0

Edité pour plus de clarté. – bcm

Répondre

0

Cela a fonctionné pour moi:

public DispatcherTimer myDispatcherTimer = new DispatcherTimer(); 

private void ViewerTab_MouseLeave(object sender, MouseEventArgs e) 
{ 
    myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000); 
    myDispatcherTimer.Tick += new EventHandler(functiontocall); 
    myDispatcherTimer.Start(); 
} 

public void functiontocall(object o, EventArgs sender) 
{ 
    // do something here 

    myDispatcherTimer.Stop(); 
} 

private void ViewerTab_MouseEnter(object sender, MouseEventArgs e) 
{ 
    myDispatcherTimer.Stop(); 
}