davidpoll.com
Archive for June, 2009
Update: Displaying background activity in a Silverlight RIA application
Posted by david.poll in Silverlight on June 11, 2009
Well, it’s been a while since I first posted on this, but the feedback was incredible, and I got some great suggestions. As a result, I’ve updated the Activity control and (finally) have a running sample on the web! The fundamental idea of the control has remained the same, as well as the mechanisms by which it can work. It’s still a prototype, but a very useful one at that!
To see the Activity control in action, take a look here: Activity Control Demo
The demo requires the Silverlight 3 beta to be installed on your machine, which can be found here: http://silverlight.net/getstarted/silverlight3/default.aspx
The demo application shows two examples of using the Activity control to display async/background activity (click the images for deep-links into the Silverlight application):
- With .NET RIA Services and the DomainDataSource, the Activity control uses element-to-element binding to indicate to the user that data is being loaded or submitted. The demo page is running live on my server using the Northwind sample database. Those of you who think you can play some dirty tricks by overwriting the data on my server (yes, I provided insert/update/delete functionality) – any attempts to do so will be quickly foiled, since the server will accept the requests, but ignore them!
- Any background activity might warrant using the activity control. The second example I’ve provided uses the activity control while I use a simple statistical method of approximating PI (yes, very geeky). It takes millions of iterations to get a mediocre approximation of PI (I know, I’m not using an efficient method, but it does do a lot of work!). Here, I’ve augmented the Activity control to allow the work to be stopped/cancelled:
So by now I’m sure you’re asking: “What’s changed?” Well, let me tell you!
- Thanks to feedback from a variety of folks, I’ve removed the all-encompassing template that included the pop-up window. That’s now baked into the control template. If you’d like to change it, you can use the Blend 3 Preview to re-template the control. In its place, I’ve added:
- A style for the progress bar. If you’d like to hide it, use a style to collapse the progress bar.
- A means for setting “ActiveContent”. The Activity control works sort of like a HeaderedContentControl. You now have ActiveContent and ActiveContentTemplate, which allow you to define in XAML what should appear above the progress bar. You can put any content you like here, and it’s how I added the cancel button in my PI calculation example. This is also great because it allows you to easily change the text from “Loading…” to whatever you prefer simply be setting the ActiveContent property to the string of your choice!
- The default template for the ActivityControl now sets IsHitTestVisible and IsEnabled to false on its content immediately when IsActive becomes true. In my old prototype, this only happened when the Activity UI became visible, which meant users could continue to interact with the content while it was busy – a potentially dangerous combination if the user’s interactions can be overriden by the asynchronous work (such as editing values in a DataGrid when the data is being reloaded). This was from a suggestion by Luke Tigaris in the comments on my last post. Let me know what you think!
- You can now call ResetActivity() on the control to force it to honor the visibility of the control immediately rather than enforcing the display delay and minimum display time. This way, if a user cancels the background work, you can force the Activity UI to be hidden immediately.
Anyhoo, let me know what you think of the changes! I’ve gotten lots of great feedback on the control so far, and I’m sure folks will come up with more as time goes on.
- You can download the source for the control here: Activity Control Source
- You can also download the source for the demo here: Activity Control Demo
For both of these, you’ll need the Silverlight 3 Beta. The Demo application is built using .NET RIA Services.
P.S. Big thanks again to Corrina for providing the beautiful theme I used in my application.
P.P.S. Isn’t navigation and deep-linking in the Silverlight 3 Beta cool? That’s how I made those images link directly to the corresponding pages of my demo application. I may post more on this in the future. In the meantime, take a look at the code to see just how little it took to accomplish that! (hint: MainPage.xaml in the Silverlight Navigation Application project template that’s included with the Silverlight 3 Beta Tools for Visual Studio has pretty much everything that’s required)
Update 9/14/2009 – I’ve made a small update to the Activity control to fix a performance issue. You can find it here.
.NET RIA Services, Activity Control, BusyIndicator, Navigation, Silverlight, Silverlight 3 Beta, WCF RIA Services
-
You are currently browsing the archives for June, 2009
Recent Posts
- Pitch Perfect for Android now available
- Tag Master for Android now available
- Pitch Perfect now available for free!
- Quickly building a trial mode for a Windows Phone application
- To XAML, with love (an experiment with XAML Serialization in Silverlight)
- Taking Microsoft Silverlight 4 Applications Beyond the Browser (TechEd WEB313)
- Common Navigation UI and Authorization-driven Sitemaps
- Samples updated and code in comments
Tags
.NET RIA Services Activity Control Android Authorization Barbershop Blend BusyIndicator CollectionView ContentLoader Controls Data Binding Dynamic Navigation Fun Konami Code logging MIX '10 Navigation Off-Topic Out-of-browser PDC PDC09 Personal Pitch Perfect Printing Projects Relative Links Server Silverlight Silverlight 3 Silverlight 3 Beta Silverlight 4 Silverlight 4 Beta Silverlight 4 RC Silverlight and Beyond (SLaB) Silverlight Toolkit Sitemap Tag Master TechEd TechEd North America 2010 Trusted Applications Validation Visual Studio 2010 WCF RIA Services Windows Phone 7 XAMLTwitter: @depoll
- What a great first week at the new job! It's great to feel so energized by work.February 4, 2012 7:08
- @andruwang Amen.February 3, 2012 7:50
- @andruwang @ParseIt Likewise -- it's been a fantastic first week!February 3, 2012 6:49
Disclaimer
The content on this site represents my own personal opinions and thoughts at the time of posting, and does not reflect those of my employer in any way.
Warning: Missing argument 2 for tweetable_write_widget() in /home3/depollco/public_html/davidpoll/wp-content/plugins/tweetable/tweetable.php on line 137

