There is an IsInDesignMode property that you can use. In some cases, this is not accurate, therefore, you can also check the UsageMode .
public static bool IsRunningInIdeContext
{
get {
if (DesignerProperties.IsInDesignMode)
return true;
return LicenseManager.UsageMode == LicenseUsageMode.Designtime;
}
}
source
share