Created
April 24, 2013 13:27
-
-
Save eternaltung/5452115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows; | |
using System.Windows.Media.Animation; | |
namespace WpfApplication1 | |
{ | |
public partial class MainWindow : Window | |
{ | |
Storyboard sb_timer = new Storyboard() { Duration = TimeSpan.FromSeconds(1) }; | |
int sec = 5; | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
sb_timer.Completed += sb_timer_Completed; | |
sb_timer.Begin(); | |
} | |
void sb_timer_Completed(object sender, EventArgs e) | |
{ | |
if (sec > 0) | |
{ | |
sec--; | |
timerText.Text = sec.ToString(); //timerText是介面上的一個TextBlock | |
sb_timer.Begin(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment