Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact


Show a MessageBox in Silverlight 2 Beta 1

Since Silverlight is just a subset of WPF, there are alot of things missing. One missing thing I found is the System.Windows.MessageBox. I'm a little puzzled as to why they would have left this out, but I imagine MessageBox's are handled very differently in different Operating Systems. It's probably a little work to get it working on both Mac and Windows, but I hope it gets into the final release. It's not a major feature, but one that is used quite often when developing desktop applications, so I can see it being used alot in Silverlight applications.

Anyways, here's a small implementation I wrote that wraps up the JavaScript Alert to give us a basic MessageBox to use for now:

public static class MessageBox
    public static void Show(string message)

Update 4/2/2008: I updated the above example to use the "HtmlPage.Window.Alert" method instead of the Invoke method; better to use the method that's already in the framework.

Also, here's the above code example in VB.NET:

Module MessageBox
    Public Sub Show(ByVal message As String)
    End Sub
End Module


blog comments powered by Disqus