Delay's Blog is the blog of David Anson, a Microsoft developer who works with the Silverlight, WPF, Windows Phone, and web platforms.
http://dlaa.me/
@DavidAns
We've just published the November 09 release of the Silverlight Toolkit in conjunction with today's unveiling of the Silverlight 4 Beta! The Silverlight 4 Beta offers a bunch of neat new features which enable even more compelling online (and offline!) applications. Stuff like bi-directional text, web cam and microphone support, a RichTextArea control, clipboard access, ICommand, an elevated-trust model, printing, notifications, right-click, and more!
Of course, the big news for this post is a new version of the Silverlight Toolkit that's perfectly suited for developing great applications on Silverlight 4. And though it seems like just yesterday that we finished off the October 09 release, there are some neat, new things in today's release for Silverlight 3, as well. You can be confident that the Silverlight Toolkit has your back whichever platform you choose! :)
My announcements are usually all about the Toolkit's Data Visualization assembly - and there are some improvements in that area - but it wasn't my primary focus this time around. If you have a look at the official release notes, you'll see there are all kinds of new things across the board. I'm not going to repeat everything here, but I do want to highlight a few things:
Partial Release Notes
ActivityControl
BusyIndicator
object
Legend
HeaderedItemsControl
Theme
TwilightBlue
ShinyRed
System.Windows.dll
BusyIndicator is in the house...
At its core, BusyIndicator is a simple wrapper control into which you put whatever makes up the UI of your application. (You can think of it as a special kind of Border with special abilities.) BusyIndicator exposes an IsBusy property which should be set to true (possibly via data binding) whenever the relevant portion of the application is busy and won't respond to user input. When this happens, BusyIndicator automatically disables its content and shows a simple UI to let the user know what's going on. It's really quite simple! :)
Border
IsBusy
true
Here's the most basic scenario:
<controlsToolkit:BusyIndicator IsBusy="{Binding MyBusyProperty}"> <!-- Content goes here... --> </controlsToolkit:BusyIndicator>
And this is how it looks when IsBusy is set:
The most common change is to customize the message, and of course that's simple to do:
<controlsToolkit:BusyIndicator IsBusy="{Binding MyBusyProperty}" BusyContent="My custom message..."> <!-- Content goes here... --> </controlsToolkit:BusyIndicator>
Yielding:
Note that the BusyContent property is of type object, so we could have used other UI elements (like Grid, Image, and Button) for a message with more than just text. Of course, sometimes you want things to be totally custom - so there are some straightforward ways to do that which don't require you to completely re-Template:
BusyContent
Grid
Image
Button
<controlsToolkit:BusyIndicator IsBusy="{Binding MyBusyProperty}" BusyContent="{Binding}"> <!-- Provide custom UI for busy display --> <controlsToolkit:BusyIndicator.BusyContentTemplate> <DataTemplate> <StackPanel> <TextBlock Text="Downloading Email" FontWeight="Bold" HorizontalAlignment="Center"/> <StackPanel Margin="6"> <TextBlock Text="{Binding MyStatus}"/> <ProgressBar Value="{Binding MyProgress}" Height="15"/> </StackPanel> <Button Content="Cancel" HorizontalAlignment="Center"/> </StackPanel> </DataTemplate> </controlsToolkit:BusyIndicator.BusyContentTemplate> <!-- Remove unnecessary default ProgressBar --> <controlsToolkit:BusyIndicator.ProgressBarStyle> <Style TargetType="ProgressBar"> <Setter Property="Visibility" Value="Collapsed"/> </Style> </controlsToolkit:BusyIndicator.ProgressBarStyle> <!-- Content goes here... --> </controlsToolkit:BusyIndicator>
Which looks like:
Another property to be aware of is the DisplayAfter property which lets you configure the initial delay before the busy indicator is shown - to avoid the annoying "on/off" flicker that would otherwise result from a lot of quick operations in succession. The BusyIndicator page of the public sample project has an interactive section where you can experiment with various delays and durations to see how this looks in action.
DisplayAfter
ImplicitStyleManager has left the building...
I wanted to show how to convert an existing application using ImplicitStyleManager over to using Silverlight 4's new implicit styling support. Because I made this change for the 11 Toolkit themes, I can tell you it is quite easy. :) Basically, it's just a matter of removing the ImplicitStyleManager attached property/properties and - where relevant - moving the ResourceDictionary of Styles into the Resources section of the parent element (or all the way up to App.xaml). Also, be sure to go through and remove any explicit assignments to the Style property or it's friends (e.g., ItemContanerStyle). (This probably isn't common in most applications, but the Toolkit Themes did it all over the place.)
ImplicitStyleManager
ResourceDictionary
Style
Resources
App.xaml
ItemContanerStyle
To make that a little more concrete, here's a simplified "before" example that makes Buttons have blue text and ListBoxItems purple:
ListBoxItem
<StackPanel controlsThemingToolkit:ImplicitStyleManager.ApplyMode="OneTime"> <!-- Styles for controls --> <StackPanel.Resources> <Style TargetType="Button"> <Setter Property="Foreground" Value="Blue"/> </Style> <Style TargetType="ListBoxItem"> <Setter Property="Foreground" Value="Purple"/> </Style> </StackPanel.Resources> <!-- Styled controls --> <Button Content="Button"/> <ListBox> <ListBoxItem Content="Item 1"/> <ListBoxItem Content="Item 2"/> </ListBox> </StackPanel>
To convert this XAML over to Silverlight 4's implicit style support, just remove the highlighted portion above. The visuals will look exactly the same, but everything is more efficient because the platform is handling it internally. And what's more, various scenarios that were tricky to get working with ImplicitStyleManager (like styling the contents of a TabControl) now "just work" thanks to the new framework support for implicit styles!
TabControl
Silverlight 4 has a lot of great improvements that really raise the bar for rich, interactive web applications. I encourage everyone to check it out today and start thinking about how to take advantage of all the new stuff! :) And when you're done with that, please check out the live Toolkit samples for Silverlight 3 or Silverlight 4, download the Toolkit installer(s) for the platform/platforms of your choice, and enjoy!