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)

    Read more...

  • 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!

    Read more...

  • 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…

    Read more...