views:

17

answers:

1

Trying to include a hoverIntent based on the following code:

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

                ChangeCurrentPanelPosition(TabPanelPosition.Bottom);
            }

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

The ChangeCurrentPanelPosition should ideally only fire after mouseleave for ~1 sec and the timer will clear if mouseEnter again.

A: 

This worked for me:

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