Silverlight/XAML – Learning by Coding

[ sl2_polyline_dynamic.xaml --> Grafik anzeigen ]

 1: <?xml version="1.0" encoding="UTF-8"?>
 2: <!-- coded by Thomas Meinike 01/09 -->
 3: <UserControl x:Class="sl2_polyline_dynamic.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 Loaded="CreatePolylines"/>
 9: 
10: 
11:   <!-- // zusätzlich verwendeter VB.NET-Code in Page.xaml.vb:
12: 
13:   Partial Public Class Page
14:     Inherits UserControl
15: 
16:     Public Sub New()
17:       InitializeComponent()
18:     End Sub
19: 
20:     Private Sub CreatePolylines(ByVal sender As System.Object_
21:                                 ByVal e As System.Windows.RoutedEventArgs)
22: 
23:       Dim sin_kurve As New Polyline
24:       Dim cos_kurve As New Polyline
25:       Dim punkt As System.Windows.Point
26: 
27:       sin_kurve.Stroke = New SolidColorBrush(Color.FromArgb(25525500))
28:       sin_kurve.StrokeThickness 1
29:       cos_kurve.Stroke = New SolidColorBrush(Color.FromArgb(25500255))
30:       cos_kurve.StrokeThickness 2
31: 
32:       For 0 To 800 Step 0.5
33:         punkt = New System.Windows.Point(i300 100 Math.Sin(50))
34:         sin_kurve.Points.Add(punkt)
35: 
36:         punkt = New System.Windows.Point(i300 100 Math.Cos(50))
37:         cos_kurve.Points.Add(punkt)
38:       Next
39: 
40:       sender.children.Add(sin_kurve)
41:       sender.children.Add(cos_kurve)
42: 
43:     End Sub
44: 
45:   End Class
46: 
47:   -->
48: 
49: </UserControl>

[zum Anfang]