DCSIMG
Hello World Silverlight on a Blog Post - David Sackstein's Blog

Hello World Silverlight on a Blog Post

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>

Published Friday, July 17, 2009 1:57 PM by David Sackstein

Comments

# http://silverlight.net/community/

Saturday, July 18, 2009 8:45 PM by TrackBack

# re: Hello World Silverlight on a Blog Post

Saturday, December 12, 2009 1:20 AM by gapedews

I should notify my friend about your post.

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above:
Powered by Community Server (Commercial Edition), by Telligent Systems