Archives

Archives / 2009 / March
  • Silverlight 3 - Playing with Perspective 3D

    Silverlight 3 allows you to apply 3D transformation to XAML elements.

    I created a sample to try different settings (RotationX, CenterOfRotation, LocalOffset, …) on a picture.

    PlaneProjection

    Here is a basic sample to apply some rotations to a picture:

    <StackPanel>
        <StackPanel.Projection>
            <PlaneProjection RotationX="10" RotationY="20" RotationZ="30"/>
        </StackPanel.Projection>
        <Image Source="Logo.png" />
    </StackPanel>


    This is also supported in Expression Blend:

    Blend 3 Projection editor

    The result:

    Silverlight 3 Perspective 3D

    Note you can apply 3D to any xaml objects like DataGrid or TextBox, and doing this user can still interact with them live!

    Element-to-Element Binding

    My sample do not use any code to apply 3D thanks to the new Element-to-Element Binding in Silverlight 3: you can link 2 elements declaratively.
    I use this to bind my Sliders to each 3D properties (RotationX, RotationY, …). Here the Rotation value change while the user move the slider:

    <Slider Value="{Binding RotationX, Mode=TwoWay, ElementName=projection}" Minimum="0" Maximum="360"/>

    Dynamic XAML and OpenFileDialog

    I also added the possibility to dynamically load XAML from a file. This is done via the OpenFileDialog control and the static Load() method of the XamlReader class.

    private void LoadXAML()
    {
        OpenFileDialog ofd = new OpenFileDialog();
        ofd.Multiselect = false;
        ofd.Filter = "XAML Files (*.xaml)|*.xaml";
        if (ofd.ShowDialog().Value)
        {
            string xaml = ofd.File.OpenText().ReadToEnd();
            UIElement elem = XamlReader.Load(xaml) as UIElement;
            contentPanel.Children.Clear();
            contentPanel.Children.Add(elem);
        }
    }

    Note any dynamically loaded XAML file should have the xmlns namespace declaration in it:

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


    Sample ScreenCast

    Download the code (Silverlight 3 beta)

  • Silverlight Physics Helper won at MIX09 Show Off!

    Wow my buddy Andy won first place at the MIX09 Show Off contest with an awesome video featuring his Physics Helper Library in Silverlight.

    With the Physics Helper Library you can quickly add physics to your Silverlight apps. I have been using it for a while, it is very easy and integrate well with Expression Blend. Watch the video, so funny and informative!

    Visit his website to learn more and try his physics samples and games.

  • Silverlight EnableFrameRateCounter not displayed in IE status bar

    As you may know you can set the EnableFrameRateCounter="true" property of the <asp:Silverlight> control to display the actual Silverlight framerate in the status bar of the browser.

    (You can also set the enableFramerateCounter param if you use the <object> tag or even enable it by code:

    Application.Current.Host.Settings.EnableFrameRateCounter = true;)

    But if nothing appears in your IE status bar you may have to change some security settings:

    In IE go to: Tools / Options / Security

    Select “Internet” zone and “Custom level…”
    In the “Settings” window go to the “Scripting” section and enable “Allow status bar updates via script”.

     ie-settings

  • Silverlight 3 new business app features

    This has just been announced at MIX09 keynote, Silverlight 3 is available in beta and comes with new features very much business application oriented (as well as media and graphics improvements). Concerning application development improvements Silverlight 3 adds:

    • Navigation Framework
    • Deep links, SEO, browser history integration
    • DataGrid grouping, pagination
    • DomainDataSource (object data source on the client)
    • Element-to-Element Binding
    • Validators error template
    • New controls: DataForm (DetailsView like), DataPager
    • Multi-tier REST data support
    • Authentication

    With such new features, Silverlight 3 enable developers to build real LOB application, and what’s amazing is that Silverlight 3 is 40KB smaller than v2!

    Silverlight 3 is now (march 2009) in public beta (but no go-live) so you can try all this right now!

  • Silverlight and SEO

    Did you know that silverlight.net has some interesting whitepapers ?

    I suggest this one if you are interested in SEO (Search Engine Optimization) for Silverlight applications:
    > http://silverlight.net/learn/whitepapers/seo.aspx

    The article is a bit old but it shows some techniques (not all) on Silverlight SEO and it mention an online tool to get a search engine view of your website (so without Silverlight):
    > http://seo-browser.com

    If you are interested on the subject I also posted some links back in may 2008:

    http://weblogs.asp.net/lduveau/archive/2008/05/27/silverlight-accessibility-seo-and-flash-flex-comparison.aspx

  • Get Silverlight xap and hosting page URL

    Very simple but I am often asked this during trainings:

    Get the URL to the current xap file:
        App.Current.Host.Source.AbsoluteUri

    Sample:
        http://www.myhost.com/ClientBin/SilverlightApplication1.xap

     

    Get the full URL of the page hosting the xap (with QueryStrings):
        HtmlPage.Document.DocumentUri.ToString()

    Sample:
        http://www.myhost.com/SilverlightApplication1.aspx?param=1

  • RIAstats.com shows Silverlight adoption

    There has been lot’s of buzz those days around Silverlight adoption and RIA plug-in deployments.

    While Adobe believe that “Silverlight has really fizzled”, Microsoft claims that Silverlight is installed on “more than 1 in 4 computers”.

    Let the numbers speak: This website displays charts on real world RIA plug-in deployments.

    www.riastats.com

    Statistics are collected from 1,500,000 daily unique browsers across more than 40 sites over the past 30 days - No mention of which sites and what they talks about (newspaper? weather? games? books? sport? / US? European? / private? public? / social network? ……).

    Note that you can filter by Browser, OS or Country.

    According to those stats, as of March 2009, Silverlight is installed on 21% of computers connected to the internet.

    What amaze me is that Flash 10 is already installed on more than 53% computers!!!! It was released on october 14, 2008 the exact same date as Silverlight 2 release. In 4 months Flash 10 has been spread on more than half computers worldwide (connected to the Net): this is huge! Of course it benefits from the actual auto update.

    I have always believed that Flash plug-in is good for Silverlight, because people are used to install plug-in in their browser; thanks to Flash people actually knows *what* a plug-in is. Moreover Silverlight is a plug-in by Microsoft, and not any obscure third party company, not to mention the optional windows update which will help for sure. So I don’t worry about Silverlight, it will be on every machine sooner than later. Sweet.

  • Silverlight Tour featured at the MVP Summit 2009

    That was just before the Keynote in the big room!

    The MVP Summit was also a great opportunity to meet community experts.

    3 Silverlight geeks:
    - Shawn Wildermuth (Silverlight Tour across USA)
    - David Silverlight (What a name!)
    - Laurent Duveau (Silverlight Tour in Canada and France)

    Speaking of the Silverlight Tour we now take care of the training across Canada, so stay tuned for new dates in Vancouver, Ottawa, Toronto, Halifax…

  • Microsoft MVP Summit 2009

    This year again, I took part in the Microsoft MVP Summit in Seattle. Got some great information on Silverlight, nice contact with the products team. Some really cool stuff I will talk later in march.

    Part of the Canadian delegation (quieter this year):

    But the MVP Summit is more a social than technical event (let’s say the technical part is too short). I had lots of fun talking with Canadian MVPs as well as buddies like Shawn Wildermuth, Jean-Luc David, Andy Beaulieu, Chris Sutton, Daniel Crenna, Grégory Renard, Frédéric Colin, Thomas Lebrun, seing ScottGu and others Microsoft Gurus… It was a blast and I can’t wait for next year!

    Next… MIX Las Vegas!