Silverlight/XAML – Learning by Coding
1: <?xml version="1.0" encoding="UTF-8"?>
2: <!-- coded by Thomas Meinike 08/08 -->
3: <UserControl x:Class="sl2_htmldom_s2h.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: <TextBlock Canvas.Left="30" Canvas.Top="20" Foreground="#00C"
11: FontSize="18" FontFamily="Arial" Text="Interaktion zwischen Silverlight und HTML-DOM"/>
12:
13: </Canvas>
14:
15:
16: <!-- // zusätzlich verwendeter VB.NET-Code in Page.xaml.vb:
17:
18: Imports System.Windows.Browser
19:
20: Partial Public Class Page
21: Inherits UserControl
22:
23: Public Sub New()
24: InitializeComponent()
25:
26: Dim doc As HtmlDocument = HtmlPage.Document
27: Dim pel As HtmlElement = doc.CreateElement("p")
28: pel.SetStyleAttribute("color", "red")
29: pel.SetStyleAttribute("font-family", "sans-serif")
30: pel.SetAttribute("innerText", "Neues HTML-Absatz-Element wurde aus dem Silverlight-Kontext heraus erzeugt.")
31: If Not IsNothing(doc.GetElementById("SilverlightPlugInHost")) Then
32: doc.GetElementById("SilverlightPlugInHost").AppendChild(pel)
33: End If
34: End Sub
35:
36: End Class
37:
38: -->
39:
40: </UserControl>
[zum Anfang]