Here is the proper way to check for IsInDesignMode for 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 Blend and Visual Studio.
/// DesignerProperties.GetIsInDesignMode() that many uses only works in Blend.
/// </summary>
public static bool IsInDesignMode
{
get
{
if (_isInDesignMode == null)
{
// At design-time, Application.Current is "Application".
if (Application.Current.GetType() == typeof(System.Windows.Application))
{
_isInDesignMode = true;
}
else
{
_isInDesignMode = false;
}
}
return _isInDesignMode.Value;
}
}
}
Fork
0 Feedback
You must log in before you can give any feedback
You must log in before you can post a comment


483
0




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