#region IsInDesignMode
/// <summary>
/// 是否处于设计状态(处于VS设计界面)
/// 主要是使用此标志,避免设计阶段调用执行后台交互代码
/// </summary>
private static bool? _isInDesignMode;
public static bool IsInDesignMode
{
get
{
if (Assembly.GetEntryAssembly() == null)
return false;
if (!_isInDesignMode.HasValue)
{
var prop = DesignerProperties.IsInDesignModeProperty;
_isInDesignMode = (bool)DependencyPropertyDescriptor
.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue;
}
return _isInDesignMode.Value;
}
}
#endregion
是否处于设计状态(处于VS设计界面)
最新推荐文章于 2020-12-24 09:14:01 发布