Silverlight1.0サンプルソース集

Microsoft Silverlight1.0のサンプルソースを無料で紹介

XAMLの基礎

サンプルソース

リンク

デジタル時計1

Microsoft Silverlight1.0(XAML & Javascript)で作るデジタル時計です。
サンプルソースは下です。

XAMLのサンプルソース

   

<Canvas

xmlns="http://schemas.microsoft.com/client/2007"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Background="#FF000000" Height="11050" Width="1650"

Loaded="onLoaded"

>

<Canvas.Resources>

<!-- Timer Storyboard -->

<Storyboard Duration="0:00:00" x:Name="timerStoryboard" />

</Canvas.Resources>

<TextBlock x:Name="time" Text="aaa" FontSize="46" Canvas.Top="100" Canvas.Left="50">

<TextBlock.Foreground>

<SolidColorBrush Color="#FFFFFFFF"/>

</TextBlock.Foreground>

</TextBlock>

</Canvas>

   

Javascriptのサンプルソース

   

function onLoaded(sender, e)

{

var timer = sender.FindName("timerStoryboard");

timer.AddEventListener("Completed",timerCompleted);

timer.begin();

}

function timerCompleted(sender, e)

{

var date = new Date();

var hour = date.getHours();

var min = date.getMinutes();

var sec = date.getSeconds();

if (hour<10){ hour = "0" + hour; }

if (min<10){ min = "0" + min; }

if (sec<10){ sec = "0" + sec; }

sender.findName("time").Text = hour.toString()+":"+min.toString()+":"+sec.toString();

sender.begin();

}