Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #53 – MessageBox is now Available in Silverlight 2

In Silverlight 2 you can now put up Message Boxes. The call is simple and straight forward and can be made without any input from a user.

This method takes the following three parameters with the last parameters being optional:

  1. String – The message you want to display
  2. String – The caption you want to display
  3. MessageBoxButton – Either MessageBoxButton .OKCancel or MessageBoxButton .OK

It returns a MessageBoxResult which you can use to check which button the user clicked.

Here is an example that displays an initial message, then prompts the user for input on whether to play again:

MessageBox.Show("You won the game!");
 
MessageBoxResult result = MessageBox.Show("Do you want to play again?", "Restart", MessageBoxButton.OKCancel);
 
if (result == MessageBoxResult.OK)
{
}

  Thank you,
--Mike Snow

 Subscribe in a reader

Comments

Microsoft Weblogs said:

In Silverlight 2 you can now put up Message Boxes. The call is simple and straight forward and can be

# September 30, 2008 3:04 PM

trainsdse said:

I must be missing something, what namespace should I use to get the MessageBox.Show method?  I'm using v2b2.

Thanks,

Thomas

# September 30, 2008 3:23 PM

mike.snow said:

Trainsdse - You will need to get the RCO of Silverlight 2. Check a few blogs down for details. Thanks.

# September 30, 2008 4:21 PM

Dew Drop – September 30, 2008 (Evening Edition) | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop – September 30, 2008 (Evening Edition) | Alvin Ashcraft's Morning Dew

# September 30, 2008 10:29 PM

Eloff said:

I'm more interested in how MessageBox was implemented.

Surely it must block the thread it's called on, and it can be called on the UI thread?

So I would think that it must be rendered on a different thread in order to work (which means we can do that?), and that when a MessageBox is visible the browser must hang.

Am I correct?

# October 1, 2008 2:22 AM

2008 October 01 - Links for today « My (almost) Daily Links said:

Pingback from  2008 October 01 - Links for today « My (almost) Daily Links

# October 1, 2008 3:56 AM

Silverlight news for October 1, 2008 said:

Pingback from  Silverlight news for October 1, 2008

# October 1, 2008 4:58 AM

Community Blogs said:

In this post: Mike Snow, Bill Reiss, Jesse Liberty, Harsh Bardhan, Tim Heuer, Matthias Shapiro, and Jeff

# October 1, 2008 9:54 AM

mike.snow said:

Hi Eloff - I do not have insight to how it works behind the scenes.

A good place to ask might be here: silverlight.net/.../35.aspx

Thanks.

# October 1, 2008 1:59 PM

Mirrored Blogs said:

Post: Approved at: Oct-8-2008 Tip:How to Popup a Browser Window "Let’s say a user clicks on a button

# October 8, 2008 5:50 AM

Visual Web Developer Team Blog said:

Silverlight Tip of the Day #57 Title: How to Dynamically Load a Silverlight Control within another Silverlight

# October 8, 2008 11:05 PM

MS Tech News » Silverlight Tips of the Day ??? Week 8 said:

Pingback from  MS Tech News » Silverlight Tips of the Day ??? Week 8

# October 27, 2008 3:26 PM

MS Tech News » Silverlight Tips of the Day ??? Week 8 said:

Pingback from  MS Tech News » Silverlight Tips of the Day ??? Week 8

# October 27, 2008 3:32 PM