Silverlight/XAML – Learning by Coding

[ sl2_listbox.xaml --> Grafik anzeigen ]

 1: <?xml version="1.0" encoding="UTF-8"?>
 2: <!-- coded by Thomas Meinike 08/08 -->
 3: <UserControl x:Class="sl2_listbox.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:     <ListBox Width="250" Canvas.Left="30" Canvas.Top="30"
11:       SelectionChanged="Auswahl" x:Name="liste">
12:       <ListBoxItem Content="Eintrag 1"/>
13:       <ListBoxItem Content="Eintrag 2"/>
14:       <ListBoxItem Content="Eintrag 3"/>
15:       <ListBoxItem Content="Eintrag 4"/>
16:       <ListBoxItem Content="Eintrag 5"/>
17:     </ListBox>
18: 
19:     <TextBlock Canvas.Left="30" Canvas.Top="150"
20:       Foreground="#F00" Text="..." x:Name="ausgabe"/>
21:     
22:   </Canvas>
23: 
24: 
25:   <!-- // zusätzlich verwendeter VB.NET-Code in Page.xaml.vb:
26: 
27:   Partial Public Class Page
28:     Inherits UserControl
29: 
30:     Public Sub New()
31:       InitializeComponent()
32:     End Sub
33: 
34:     Private Sub Auswahl(ByVal sender As Object_
35:       ByVal e As System.Windows.Controls.SelectionChangedEventArgs)
36:       ausgabe.Text "Eintrag " + (liste.SelectedIndex 1).ToString " wurde ausgewählt."
37:     End Sub
38: 
39:   End Class
40: 
41:   -->
42: 
43: </UserControl>

[zum Anfang]