UPDATE: Notification box has been updated: Take a look at http://wpassets.codeplex.com, the new home place for NotificationBox and others.
I’ve wrote a custom message box called NotificationBox for the Windows Phone 7. It gives you an option to pick whatever button you like to have inside the message box. Also It provides a cool feature which is ‘Show this message again’ with isolated settings persistency so you won’t have to create this mechanism by yourself each time you want to give an option to the user suppressing a message.
The usage is similar to the regular message box, except for the fact that you can pass commands with custom actions instead of return values – then switch/ifs.
For example:
NotificationBox.Show( "Exit", "Are you sure?", new NotificationBoxCommand("Yes", () => { }), new NotificationBoxCommand("No", () => { }));
NotificationBox.Show( "Erase", "You are about to loose your data!", new NotificationBoxCommand("Ok", () => { }), new NotificationBoxCommand("Cancel", () => { }));
NotificationBox.Show( "Choose", "Choose an option.", new NotificationBoxCommand("Save", () => { }), new NotificationBoxCommand("Load", () => { }));
NotificationBox.Show( "Custom", "Click on any of the buttons below.", new NotificationBoxCommand("Xxx", () => { }), new NotificationBoxCommand("Xxx", () => { }), new NotificationBoxCommand("Zzz", () => { }));
Yields:
Another version of the Show method called ShowAgain, gives an option to suppress a message:
NotificationBox.ShowAgain( "Show Again", "Uncheck the show again message and this message won't appear again.", "Show this message again", false, suppressed => { }, GetType().ToString(), new NotificationBoxCommand("Xxx", () => { }), new NotificationBoxCommand("Xxx", () => { }), new NotificationBoxCommand("Zzz", () => { }));
NotificationBox.ShowAgain( "Show Again", "Check the show again message so this message will appear again.", "Show this message again", true, suppressed => { }, GetType().ToString(), new NotificationBoxCommand("Xxx", () => { }), new NotificationBoxCommand("Xxx", () => { }), new NotificationBoxCommand("Zzz", () => { }));
The first call with false, displays the following message:
Now calling the same method again with the same parameters (at least with GetType().ToString()), won’t open the message in case that the user suppressed it by unchecking the check box.
The second snippet (fourth param is true) forces the message to open event if suppressed, but now the same message appears and the checkbox left unchecked. The user have an option to check it again.
I’ll be happy to have inputs, so please – don’t be shy ;)
You can download the source from CodePlex.