最近开始研究WPF了,之前对于Silverlight有了一定的认识,所以现在觉得wpf不是很陌生,在某些游戏的人物动画中 ,会用到DispatcherTimer类,现在就这个类进行说明和实践一下。
DispatcherTimer类位于System.Windows.Threading命名空间下,类似于winform的Timer类。
启动Microsoft Visual Studio 2008(sp1),创建一个WPF的项目,然后在wyd.xaml文件中加入一个Label控件用于显示


1 <Window x:Class="WPFGameCourse.wyd"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 Title="wyd" Height="300" Width="300">
5 <Grid>
6 <Label Height="28" Margin="64,94,94,0" Name="label1" VerticalAlignment="Top"></Label>
7 </Grid>
8 </Window>
9
然后在相应的wyd.xaml.cs中加入如下代码:


1

2



3

4

5



6

7

8

9

10

11

12

13

14



15

16

17

18

19



20

21

22

23

24
