Starting Prism in Silverlight

So I got my hands onto Prism and I found it extremely intriguing. I created a bunch of applications on that and its been a fun learning experience. Though its very interesting, the scarcity of reference material on Internet forced me to create a tutorial here.

There will be a couple of posts on this following this one. I’ll update the links to them later on.


The following code is rough and can be ignored completely
xmlns:Regions=”clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation”

Displaying 'Window-Style' error messages in Silverlight

To display ‘window-style’ (I mean something like a Javascript alert page that has a message and a ‘close’ button) error message in a silverlight form you have two options – An easy but not-so-cool one and a not-so-easy but a cool one.

First solution is to display a regular javascript alert message using Silverlight’s DOM support. This is as simple as follows:

System.Windows.Browser.HtmlPage.Window.Alert("Hello World");

The second solution is to use the Silverlight popup control. The advantage of this is that you can display anything you want. If you were to show a message box with some formatting, you could do that with the popup control. A problem you might have with a popup control is the amount of XAML that you need to write each time you have to display a popup. My suggestion for this is to create a Template for a popup and display a user control (The user control contains a textblock with a message or any other content that you want) in the popup. This way all your popups have the same ‘look-and-feel’.

Here is a tutorial by Jesse Liberty a.k.a the ‘Silverlight Geek’ on using Silverlight Popup controls.

Tutorial on Silverlight Popup by Jesse Liberty