Hello World Silverlight on a Blog Post

17 ביולי 2009

תגובה אחת

This is a test page that I wrote to check that I can run Silverlight applications in a blog post. This way I will be able to demonstrate Silverlight and WPF (not all) stuff without you having to necessarily download and compile it.

It works! and the possibilities are endless : )

Get Microsoft Silverlight

Here is the XAML for this Hello World blog-hosted Silverlight application:

<UserControl x:Class="HelloWorld.MainPage"

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

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

   Width="400" Height="300"

   >

   <UserControl.Resources>

      <Storyboard x:Key="storyBoard">

         <DoubleAnimation

                 Storyboard.TargetName="button"

                 Storyboard.TargetProperty="FontSize"

                 To="30"

                 Duration="0:0:2"

                 AutoReverse="True"

           >

         </DoubleAnimation>

      </Storyboard>

   </UserControl.Resources>

   <Grid x:Name="LayoutRoot" Background="White">

      <Button Name="button" Height="100" Width="200" FontSize="20"

             Click="Button_Click">

         <TextBlock>Hello World</TextBlock>

      </Button >

   </Grid>

</UserControl>

In order to start the animation I used this code behind implementation for Button_Click:

    private void Button_Click(object sender, RoutedEventArgs e)

    {

        Storyboard storyBoard = this.Resources["storyBoard"] as Storyboard;

        storyBoard.Begin();

    }

I was able to load the Silverlight control into this page simply by editing the HTML inserting the following:

   <div id="silverlightControlHost">

      <object data="data:application/x-silverlight-2,"

             type="application/x-silverlight-2"

             width="100%" height="100%">

         <param name="source"

          value="http://blogs.microsoft.co.il/blogs/davids/../HelloSilverlightOnBlog.zip/>

         <param name="background" value="white" />

         <param name="minRuntimeVersion" value="3.0.40624.0" />

         <param name="autoUpgrade" value="true" />

         <a href=http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0

           style="text-decoration:none">

            <img src=http://go.microsoft.com/fwlink/?LinkId=108181

                alt="Get Microsoft Silverlight" style="border-style:none"/>

         </a>

      </object>

  </div>

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

תגובה אחת

  1. gapedews12 בדצמבר 2009 ב 1:20

    I should notify my friend about your post.

    הגב