0
我想要做的就是向我的5歲女兒展示號碼如何在屏幕上計數。如何在WPF屏幕上獲得一個數字以進行計數?
這等待135秒,然後顯示「135」。
我必須改變什麼才能顯示數字?
XAML:
<Window x:Class="TestCount234.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="768" Width="1024">
<StackPanel>
<TextBlock
HorizontalAlignment="Center"
FontSize="444" x:Name="TheNumber"/>
</StackPanel>
</Window>
代碼背後:
using System.Windows;
using System.Threading;
namespace TestCount234
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Window1_Loaded);
}
void Window1_Loaded(object sender, RoutedEventArgs e)
{
for (int i = 0; i <= 135; i++)
{
TheNumber.Text = i.ToString();
Thread.Sleep(1000);
}
}
}
}
謝謝,這樣的作品,並在5歲的關注範圍,謝謝! – 2009-12-16 18:59:28