Silverlight/XAML – Learning by Coding

[ sl2_repeatbutton.xaml --> Grafik anzeigen ]

 1: <?xml version="1.0" encoding="UTF-8"?>
 2: <!-- coded by Thomas Meinike 08/08 -->
 3: <UserControl x:Class="sl2_repeatbutton.Page"
 4:   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
 5:   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
 6:   Width="800" Height="600">
 7: 
 8:   <Canvas>
 9: 
10:     <StackPanel Orientation="Horizontal" Canvas.Left="30" Canvas.Top="30">
11: 
12:       <RepeatButton x:Name="minus" Click="PlusMinus" Height="20" Width="20" 
13:         ClickMode="Press" Content="-" Margin="10,0,10,0"/>
14:     
15:       <TextBlock x:Name="wert" Foreground="#F00" Text="0"/>
16: 
17:       <RepeatButton x:Name="plus" Click="PlusMinus" Height="20" Width="20" 
18:         ClickMode="Press" Content="+" Margin="10,0,10,0"/>
19:         
20:    </StackPanel>
21: 
22:   </Canvas>
23: 
24: 
25:   <!-- // zusätzlich verwendeter VB.NET-Code in Page.xaml.vb:
26: 
27:   Partial Public Class Page
28: 
29:     Inherits UserControl
30: 
31:     Public Sub New()
32:       InitializeComponent()
33:     End Sub
34: 
35:     Private Sub PlusMinus(ByVal sender As ObjectByVal e As System.Windows.RoutedEventArgs)
36:       If sender.Name "plus" Then
37:         wert.Text Val(wert.Text) + 1
38:       End If
39: 
40:       If sender.Name "minus" And Val(wert.Text) > 0 Then
41:         wert.Text Val(wert.Text) - 1
42:       End If
43:     End Sub
44: 
45:   End Class
46: 
47:   -->
48: 
49: </UserControl>

[zum Anfang]