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: Loaded="FontLoad">
6:
7: <TextBlock Text="Der folgende Text wird mit einer heruntergeladenen Schriftart (TTF) formatiert:"
8: Canvas.Left="30" Canvas.Top="30" FontSize="14" Foreground="#000"/>
9:
10: <TextBlock x:Name="ausgabe" Text="..." Canvas.Left="30" Canvas.Top="60" Foreground="#090"/>
11:
12: <TextBlock Text="Font-Quelle unter CC-Lizenz: http://www.yanone.de/typedesign/tagesschrift/"
13: Canvas.Left="30" Canvas.Top="130" FontSize="14" Foreground="#00C"
14: MouseEnter="TextOver" MouseLeave="TextOut" MouseLeftButtonDown="HyperLink"
15: Tag="http://www.yanone.de/typedesign/tagesschrift/"/>
16:
17:
18: <!-- // zusätzlich verwendeter JavaScript-Code:
19:
20: function FontLoad(sender,eventArgs)
21: {
22: var ausgabe=sender.findName("ausgabe");
23: var dl=sender.getHost().createObject("downloader");
24:
25: dl.addEventListener("DownloadFailed",function(sender,eventArgs)
26: {
27: ausgabe.text="Fehler beim Font-Download!";
28: });
29:
30: dl.addEventListener("Completed",function(sender,eventArgs)
31: {
32: if(sender.status==200)
33: {
34: ausgabe.setFontSource(sender);
35: ausgabe.fontFamily="Yanone Tagesschrift";
36: ausgabe.fontSize=48;
37: ausgabe.text="Yanone Tagesschrift";
38: }
39: else ausgabe.text="Fehler beim Font-Download!";
40: });
41:
42: dl.open("GET","media/YanoneTagesschrift.ttf");
43: dl.send();
44: }
45:
46: -->
47:
48: </Canvas>
[zum Anfang]