Skip to content

Instantly share code, notes, and snippets.

@camilomartinez
Last active August 29, 2015 14:23
Show Gist options
  • Save camilomartinez/1bdb9b6a486fce795dab to your computer and use it in GitHub Desktop.
Save camilomartinez/1bdb9b6a486fce795dab to your computer and use it in GitHub Desktop.
Check design mode before calling MVVM light Distpatcher helper
using System;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Threading;
namespace MvvmLight.Helpers
{
public class DesignAwareDispatcherHelper
{
// ReSharper disable once InconsistentNaming
public static void CheckDesignModeInvokeOnUI(Action action)
{
if (action == null)
{
return;
}
if (ViewModelBase.IsInDesignModeStatic)
{
action();
}
else
{
DispatcherHelper.CheckBeginInvokeOnUI(action);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment