WPF C# - Timer countdown

前端 未结 4 1006

How can I implement the following in my piece of code written in WPF C#?

I have a ElementFlow control in which I have implemented a SelectionChanged event which (by defi

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 10:44

    look here is the code of how to use DispatherTimer and you can add your own logic in it. that will depends on you..

     private void ListBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(2000);
            timer.Tick += timer_Tick;
            timer.Start();
    
        }
    
        void  timer_Tick(object sender, object e)
        {
           // show your message here..
        }
    

提交回复
热议问题