Posts Tagged Silverlight Toolkit

Silverlight Toolkit November 2009: Activity Control –> BusyIndicator (a.k.a. Update 3: Displaying background activity in a Silverlight RIA application)

Wow!  What a week!  PDC, the Silverlight 4 Beta, and now the November 2009 release of the Silverlight Toolkit!  There’s been a ton of great news and exciting announcements, and now I can share with you that the Activity control, first blogged here, is now a part of the Silverlight Toolkit!

Awesome!  What does that mean for the Activity control?

During this transition, the Activity control underwent a few changes (thanks to my colleagues working on the Toolkit – David Anson and Jeff Wilcox) to make it more generally palatable:

  • The control has been renamed from “Activity” to “BusyIndicator” in order to avoid confusion with the concept of an Activity (sounds a lot like “Task”)
    • Similarly, “IsActive” is now “IsBusy”, and the visual states have been renamed appropriately as well.
  • AutoBind and related properties have been removed once and for all.  They were a performance hog in the original versions, and they really only hit a very, very narrow scenario.  Instead, bind to a property that represents your busyness.
  • MinDisplayTime has gone away.  If you’re looking to change the minimum display time, you can re-template the control and add a duration to the transition from visible back to hidden.
  • OverlayBrush and OverlayOpacity have been replaced with a single OverlayStyle property where you can set the color/opacity of the overlay easily.
  • DisplayAfter now defaults to 0.1s instead of 0.05s

Otherwise, the control is basically the same!  Give it a shot!

With this transition, the BusyIndicator control truly becomes accessible to anyone who’s using the Silverlight Toolkit.  You can report bugs through that project on codeplex, and we’ll make sure to keep an eye on any feedback we get from you on the control.

Great… So where can I find it?

It’s simple!  Just download the November 2009 Silverlight Toolkit for either Silverlight 3 or Silverlight 4.  There are a few ways to get it:

The BusyIndicatorControl can be found in the System.Windows.Controls namespace in the System.Windows.Controls.Toolkit.dll assembly in the toolkit.

And… can I see it in action?

Yep!  David Anson created some awesome samples in the Toolkit Sample Browser for the BusyIndicator.  I’m a big fan of his work! :)

BusyIndicator is now in the Silverlight Toolkit sample browser!

I hope you all enjoy using the BusyIndicator control in your applications!  Let me know what you think!

P.S. Thanks to Jeff Wilcox, who beat me to explaining this change :)   I’ve been super-busy with PDC, so it was good to have someone start getting the word out early.  Jeff gives a great overview of what the control is meant to do and has lots of resources regarding the Silverlight Toolkit.  Check out his blog!

, , , , ,

11 Comments

Silverlight 3 Navigation: Adding transitions to the Frame control

Continuing with my recent theme of enhancing the built-in support for Navigation in Silverlight 3, I thought I’d use this post to look briefly at enhancing user experience during navigation.  On the surface, the Frame control is pretty unexciting from a UX perspective – its job is really just to display pages as a result of requests to navigate (either through the browser’s address bar, responding to HyperlinkButton clicks, or direct calls to Frame.Navigate()).  It has barely any UI of its own, and can usually be thought of as an enhanced ContentControl (incidentally, it is one!).

Most of the time, all the Frame is doing is displaying a Page, and this (in my opinion at least) is an appropriate presentation – the Frame shouldn’t get in the way of displaying my Pages.  Where I do want the Frame to intervene now and then is during page changes, allowing me to provide rich transitions when navigating from Page to Page.  The Frame control provided in the Silverlight 3 SDK doesn’t do anything for us as far as transitions go out of the box, but with a little templating magic and the Silverlight Toolkit’s TransitioningContentControl (which Jesse Liberty has a great blog post on), I think we can get the desired effect!

Let’s begin by taking a peek at the ControlTemplate for the Frame control:

<ControlTemplate TargetType="navigation:Frame">
    <Border HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}">
        <ContentPresenter Cursor="{TemplateBinding Cursor}"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          Margin="{TemplateBinding Padding}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          Content="{TemplateBinding Content}"/>
    </Border>
</ControlTemplate>

As you can see, there’s very little to it: a Border and a ContentPresenter – with all the appropriate TemplateBindings.

All we have to do to get transitions on the Frame control is replace that ContentPresenter with the TransitioningContentControl:

<ControlTemplate x:Key="TransitioningFrame" TargetType="navigation:Frame">
    <Border Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
            VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
        <toolkit:TransitioningContentControl Content="{TemplateBinding Content}"
                                             Cursor="{TemplateBinding Cursor}"
                                             Margin="{TemplateBinding Padding}"
                                             HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                             VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                             HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                             VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                             Transition="<Transition Name>" />
    </Border>
</ControlTemplate>

The “toolkit:” xml namespace uses the following definition (since you can find the TransitioningContentControl in the System.Windows.Controls namespace and the System.Windows.Controls.Layout.Toolkit assembly): xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"

To change the type of transition the Frame will use, just change the value of the Transition property on the TransitioningContentControl.

There’s not much more to it!  Short, sweet, and to the point :) .

Check out the live sample and source if you’re curious:

 

Caveats and Questions

I know you’d be disappointed if I really left it at that, so here’s the one caveat I’ve observed with this technique:

My dynamically-loaded libraries with navigation workaround will cause a few problems with this technique, since it sets the Frame’s Content property twice (once to load the DynamicPageShim, the other to load the DynamicPage itself).  The result is that you will see the Frame transition to a blank page and then to the DynamicPage with your content.  So here’s the question: how important is this transitioning behavior to you?  There are two options for how I proceed here, neither of which are truly ideal:

  1. Leave DynamicPage and DynamicPageShim as-is and live with the slight wonkiness during transitions.
  2. Make DynamicPageShim avoid changing the content of the Frame twice (making transitions work just fine :) ).  This will mean that you won’t be able to use the DynamicPageexactly as you would the standard Page (e.g. binding to "Frame.Content.MyCustomPropertyOnMyPage” won’t be possible… instead you’d have to bind to “Frame.Content.Content.MyCustomPropertyOnMyPage”).

Neither of these options significantly hampers functionality – just impacts either user experience or developer experience, but I’d love to hear your thoughts!  Do you prefer option 1 or option 2?

In the meantime, I’m working on some fun little utilities that will make dynamically loading assemblies with navigation much simpler and more declarative, and am looking forward to blogging it when it’s ready!

 

Update: Credit where credit is due

About 10 minutes after I posted this, I came across someone (Koen Zwikstra) who posted almost the exact same thing before me, and I want to make sure he gets fair mention for getting there before me :)

You can find his post here: http://firstfloorsoftware.com/blog/animated-page-navigation-in-sl3/

Sorry for duplicating!  Great stuff!

, , ,

4 Comments