Silverlight/XAML – Learning by Coding
1: <?xml version="1.0" encoding="UTF-8"?>
2: <!-- coded by Thomas Meinike 02/08 -->
3: <Canvas xmlns="http://schemas.microsoft.com/client/2007"
4: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
5:
6: <Rectangle x:Name="rechteck" Width="200" Height="100" Canvas.Left="30"
7: Canvas.Top="30" Fill="#FC6" Stroke="#6CF" StrokeThickness="2"/>
8:
9: <TextBlock Canvas.Top="150" Canvas.Left="30" FontFamily="Arial" FontSize="16"
10: Foreground="#00C" Text="Start" MouseLeftButtonDown="AniCtrl"
11: MouseEnter="TextOver" MouseLeave="TextOut"/>
12:
13: <TextBlock Canvas.Top="150" Canvas.Left="80" FontFamily="Arial" FontSize="16"
14: Foreground="#00C" Text="Pause" MouseLeftButtonDown="AniCtrl"
15: MouseEnter="TextOver" MouseLeave="TextOut"/>
16:
17: <TextBlock Canvas.Top="150" Canvas.Left="140" FontFamily="Arial" FontSize="16"
18: Foreground="#00C" Text="Weiter" MouseLeftButtonDown="AniCtrl"
19: MouseEnter="TextOver" MouseLeave="TextOut"/>
20:
21: <TextBlock Canvas.Top="150" Canvas.Left="200" FontFamily="Arial" FontSize="16"
22: Foreground="#00C" Text="Stop" MouseLeftButtonDown="AniCtrl"
23: MouseEnter="TextOver" MouseLeave="TextOut"/>
24:
25: <Canvas.Resources>
26: <Storyboard x:Name="rechteck_animation">
27: <DoubleAnimation
28: Storyboard.TargetName="rechteck"
29: Storyboard.TargetProperty="(Canvas.Left)" To="580" Duration="00:00:05"
30: RepeatBehavior="Forever"/>
31: </Storyboard>
32: </Canvas.Resources>
33:
34:
35: <!-- // zusätzlich verwendeter JavaScript-Code:
36:
37: function AniCtrl(sender,eventArgs)
38: {
39: var ani_txt=sender.text;
40: var ani_obj=sender.findName("rechteck_animation");
41:
42: if(ani_txt=="Start")ani_obj.begin();
43: else if(ani_txt=="Pause")ani_obj.pause();
44: else if(ani_txt=="Weiter")ani_obj.resume();
45: else if(ani_txt=="Stop")ani_obj.stop();
46: }
47:
48:
49: function TextOver(sender,eventArgs)
50: {
51: var txt_obj=sender;
52:
53: txt_obj.cursor="Hand";
54: txt_obj.foreGround="#F00";
55: txt_obj.textDecorations="Underline";
56: }
57:
58:
59: function TextOut(sender,eventArgs)
60: {
61: var txt_obj=sender;
62:
63: txt_obj.cursor="Default";
64: txt_obj.foreGround="#00C";
65: txt_obj.textDecorations="None";
66: }
67:
68: -->
69:
70: </Canvas>
[zum Anfang]