private static bool? _isInDesignMode;

/// <summary>
/// Gets a value indicating whether the control is in design mode (running in Blend
/// or Visual Studio).
/// </summary>
public static bool IsInDesignModeStatic
{
    get
    {
        if (!_isInDesignMode.HasValue)
        {
#if SILVERLIGHT
            _isInDesignMode = DesignerProperties.IsInDesignTool;
#else
            var prop = DesignerProperties.IsInDesignModeProperty;
            _isInDesignMode
                = (bool)DependencyPropertyDescriptor
                .FromProperty(prop, typeof(FrameworkElement))
                .Metadata.DefaultValue;
#endif
        }

        return _isInDesignMode.Value;
    }
}
Tags
Comments
Write the first comment
Leave a trace
Name *
Email *
Website
Anti SPAM * Code (1 + 8) =
Leave me a comment *
 
All comments are subject to editorial review
Post being viewed right now
Item date: 05.02.2009
Views: 739
Item date: 22.08.2009
Views: 879
Item date: 06.02.2009
Views: 2200
Item date: 07.08.2010
Views: 2460
Item date: 05.02.2009
Views: 913
Item date: 21.07.2009
Views: 1298
Item date: 01.12.2007
Views: 513
Item date: 12.04.2009
Views: 1958
Item date: 23.08.2009
Views: 1883
Item date: 19.07.2009
Views: 614