May 4, 2018

Show another window after five seconds

In your MainWindow, define a DispatcherTimer and pop up another window on Tick like this -
    DispatcherTimer timer = null;
    void StartTimer()
    {
        timer = new DispatcherTimer();
        timer.Interval = TimeSpan.FromSeconds(5);
        timer.Tick += new EventHandler(timer_Elapsed);
        timer.Start();
    }

    void timer_Elapsed(object sender, EventArgs e)
    {
        timer.Stop();

        AnotherWindow window = new AnotherWindow();
        window.Show();
    }
Call StartTimer() in your MainWindow constructor.
    public MainWindow
    {
        InitializeComponent();
        StartTimer();
    }

No comments:

Post a Comment