Simple Silverlight Sample

| コメント(0) | トラックバック(0)

Silverlight で遊び始めたので書いてみます。

まず、画面を定義する XAML です。

<Canvas
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="120"
Height="80" >
<Canvas.Background>
<LinearGradientBrush StartPoint="0,0.5"
EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FF000000" Offset="0"/>
<GradientStop Color="#FFA09E9E" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Canvas.Background>
</Canvas>
List 1: test.xaml

ついで、全体のコンテナとなる HTML ファイルを示します。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Weather Map</title>
        <script type="text/javascript" src="Silverlight.js"></script>
    </head>
    <body>
        <div id="silverlight"></div>
        <script type="text/javascript" src="test.js">
        </script>
    </body>
</html>
List 2: test.html

そして、Silverlight のメインとなる ECMA Script ファイルを示します。

// Loading silverlight
var parentElement = document.getElementById("silverlight");

Silverlight.createObject(
    "test.xaml",
    parentElement,
    "sl00",
        {
            width: "120",
            height: "80",
            background: "#FFFFFF",
            version: "1.0"
        },
        {
            onError: null,
            onLoad: null
        },
        null,
    null
);

List 3: test.js

これで、システム全体としては動きます。一応、ものを以下に張り付けておきます。

トラックバック(0)

トラックバックURL: http://www.cworld2000.com/cgi-bin/mt/mt-tb.cgi/389

コメントする

Recent Tracks

gorn708's Profile Page

このブログ記事について

このページは、gornが2008年1月28日 14:24に書いたブログ記事です。

ひとつ前のブログ記事は「○○ virus 作成の容疑者が逮捕された件」です。

次のブログ記事は「羊質虎皮とはこのことか」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。

Adwords