The message service allows a developer to show message boxes from a view model

Available for
WPF / Silverlight / WP7 / WP7 Mango

Test/Emulation service available: yes

Showing a message
To show a message from a view model, use the following code:

var messageService = GetService<IMessageService>();
messageService.Show("My first message via the service");

Showing an error
Showing a warning or error is very easy. Use the following code:

var messageService = GetService<IMessageService>();
messageService.ShowError("Whoops, something went wrong");

Requesting confirmation
It is also possible to request confirmation from the user. The number of possibilities depends on WPF, Silverlight or WP7 is used (for example, not all platforms support YesNo).

The following code must be used to request confirmation:

var messageService = GetService<IMessageService>();
if (messageService.Show("Are you sure you want to do this?", "Are you sure?", MessageButton.YesNo) == MessageResult.Yes)
{
    // Do it!
}

Last edited Jul 10, 2011 at 1:50 PM by GeertvanHorrik, version 4

Comments

No comments yet.