Sometimes it is important to prevent certain code being executed at design time.
public static bool IsDesignTime { get { return (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime); } }
In WPF applications the following code can be used instead:
public static bool IsDesignTime { get { System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()); } }