wp 实现N秒无操作后自动隐藏控件
public partial class a: PhoneApplicationPage
{
DispatcherTimer timer = new DispatcherTimer();
public a()
{
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(10);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
{
base.OnManipulationStarted(e);
timer.Stop();
this.Search.Visibility = Visibility.Visible;
SystemTray.IsVisible = true;
this.ApplicationBar.IsVisible = true;
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
timer.Interval = TimeSpan.FromSeconds(10);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
timer.Stop();
this.Search.Visibility = Visibility.Collapsed;
SystemTray.IsVisible = false;
this.ApplicationBar.IsVisible = false;
}
}