ファーストステップ

http://www.microsoft.com/japan/msdn/vstudio/Express/から以下をダウンロードしインストール。
なんかWeb DeveloperのほうはSQLうんちゃらのインストールに失敗したけどとりあえず無視w

http://silverlight-users.jp/Index.php?FirstStepのとおりにやってみるとできた。

Page.xaml

<UserControl x:Class="HelloWorld.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock x:Name="tbLabel" FontSize="16" />
        <Button Width="80" Height="40" Content="Push me" Click="Button_Click"/>
    </Grid>
</UserControl>

Page.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace HelloWorld
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            tbLabel.Text = "Hello, World";
        }
    }
}

これがうわさのpartial classか。
xamlでClick属性を補完するとcsのほうにもButton_Clickメソッドが自動的に追加されるから便利ね。

HelloWorldTestPage.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

<!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" style="height:100%;">
<head runat="server">
    <title>HelloWorld</title>
</head>
<body style="height:100%;margin:0;">
    <form id="form1" runat="server" style="height:100%;">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div  style="height:100%;">
            <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/HelloWorld.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
        </div>
    </form>
</body>
</html>

で、HelloWorld.xapにはAppManifest.xamlとHelloWorld.dllがある。

実行結果

ちなみに以下だと
第2回 明らかになったSilverlight 2の機能とプログラミングの実際【更新版】 | 日経 xTECH(クロステック)

page.xaml

<UserControl x:Class="SilverlightApplication1.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <Canvas>
            <Ellipse x:Name="ellipse" Fill="Blue" Width="100" Height="50" Canvas.Top="20" Canvas.Left="20"/>
        </Canvas>
    </Grid>
</UserControl>

page.xml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverlightApplication1
{
    public partial class Page : UserControl
    {
        bool dragInProgress = false;
        Point dragOffset;

        public Page()
        {
            InitializeComponent();
            ellipse.MouseLeftButtonDown += new MouseButtonEventHandler(ellipse_MouseLeftButtonDown);
            ellipse.MouseLeftButtonUp += new MouseButtonEventHandler(ellipse_MouseLeftButtonUp);
            ellipse.MouseMove += new MouseEventHandler(ellipse_MouseMove);
        }

        void ellipse_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragInProgress)
            {
                Point mousePoint = e.GetPosition(this);
                Canvas.SetLeft(ellipse, mousePoint.X - dragOffset.X);
                Canvas.SetTop(ellipse, mousePoint.Y - dragOffset.Y);
            }
        }

        void ellipse_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ellipse.ReleaseMouseCapture();
            dragInProgress = false;
        }

        void ellipse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ellipse.CaptureMouse();
            dragInProgress = true;
            dragOffset = e.GetPosition(ellipse);
        }
    }
}

delegateですな。

実行結果