Here are two WPF gems I found on the Internet this month.

1) For me, one of the drawbacks of the MVVM architecture was the complexity involved generating a message/dialog box from the View Model.  I found this solution on the stackoverflow website that uses Func and Action delegates, which I believe, simplifies the process.

In my View Model:

// Declare the delegates

public Func<string, string, bool>   OkCancelDialog              { get; set; }

public Action<string, string>       MessageDialogInformation    { get; set; }

public Action<string, string>       MessageDialogError          { get; set; }

I

In my View loaded event, assign MessagBox.Show method to the delegates:

void View_Loaded(object sender, RoutedEventArgs e)

{

       var vm = new ViewModel(this);

vm.OkCancelDialog           = (msg, caption) => MessageBox.Show(msg, caption, MessageBoxButton.OKCancel) == MessageBoxResult.OK;

vm.MessageDialogInformation  = (msg, caption) => MessageBox.Show(msg, caption, MessageBoxButton.OK, MessageBoxImage.Information);

vm.MessageDialogError        = (msg, caption) => MessageBox.Show(msg, caption, MessageBoxButton.OK, MessageBoxImage.Error);        

       this.DataContext = vm;

}


In my View Model, call the delegates:

if (OkCancelDialog("Message", "Caption"))

    //do something if true

else

    //else do something if false

MessageDialogInformation("Information Message", "Caption"); 

MessageDialogError("Error Message", "Caption");

2) Here is a routine I found on codeplex to allow for only one instance of a WPF application: http://wpfsingleinstance.codeplex.com/