Visual studio feeds

All Visual Studio blogs in one place

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Google+

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Search

Behavior to show a MessageBox from a ViewModel

AddThis Social Bookmark Button
Since I am a very lazy programmer and I always want to register of define services and whatnot I created this extreme, very simple behavior for showing a MessageBox from a ViewModel. I wrote the code for Windows Phone 7, but I suppose it could be used in Silverlight as well. The behavior itself is as simple as this:using System.Windows; using System.Windows.Interactivity; namespace Wp7nl.Behaviors { public class MessageBoxDisplayBehavior : Behavior { public const string MessagePropertyName = "Message"; public string Message {
get { return (string)GetValue(MessageProperty); } set { SetValue(MessageProperty, value); } } public static readonly DependencyProperty MessageProperty = DependencyProperty.Register( MessagePropertyName, typeof(string), typeof(MessageBoxDisplayBehavior), new PropertyMetadata(string.Empty, MessageChanged)); public static void MessageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var msg = e.NewValue as string; ...(Read whole news on source site)

Home : Blog List : .NET by Example : Behavior to show a MessageBox from a ViewModel