Here is the proper way to check for IsInDesignMode for WPF and Silverlight which works for both Blend and Visual Studio.
public class Bootstrapper
{
private static bool? _isInDesignMode = null;
/// <summary>
/// Returns a boolean value whether the code is currently running in design-mode.
/// This check works for both SL and WPF inside Blend and Visual Studio.
/// </summary>
public static bool IsInDesignMode
{
get
{
if (_isInDesignMode == null)
{
string app = Application.Current.ToString();
if (app == "System.Windows.Application" || app == "Microsoft.Expression.Blend.BlendApplication")
{
_isInDesignMode = true;
}
else
{
_isInDesignMode = false;
}
}
return _isInDesignMode.Value;
}
}
}
Fork
1 Feedback
You must log in before you can give any feedback
You must log in before you can post a comment


1.03k
0




Mark 'designmode' tag as 'like'
Mark 'designmode' tag as 'ignore'