Csharp/C#教程:DesignerProperties.IsInDesignMode和DesignerProperties.IsInDesignTool之间有什么区别?分享


DesignerProperties.IsInDesignMode和DesignerProperties.IsInDesignTool之间有什么区别?

DesignerProperties使用GetIsInDesignMode(element)IsInDesignTool公开两个类似的设计状态。

快速谷歌搜索显示,IsInDesignTool似乎适用于Silverlight和ExpressionBlend。 因此,也许IsInDesignMode用于VS,但其他人需要IsInDesignTool。

它们完全是一回事

IsInDesignTool
“如果元素在设计器的上下文中运行,则为true;否则为false。” IsInDesignTool的MDSDN

GetIsInDesignMode(元件)
“元素的IsInDesignMode属性值。” GetIsInDesignMode的MDSDN(元素)

然而,在每个蓝色的月亮中,Visual Studio都会失败

 DesignerProperties.GetIsInDesignMode(this) 

所以最好用

 return DesignerProperties.GetIsInDesignMode(this) || DesignerProperties.IsInDesignTool; 

如果你不想让它崩溃。

上述就是C#学习教程:DesignerProperties.IsInDesignMode和DesignerProperties.IsInDesignTool之间有什么区别?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

用于Silverlight的.Net Reflector

 public static bool GetIsInDesignMode(DependencyObject element) { if (element == null) { throw new ArgumentNullException("element"); } bool flag = false; if (Application.Current.RootVisual != null) { flag = (bool) Application.Current.RootVisual.GetValue(IsInDesignModeProperty); } return flag; } public static bool IsInDesignTool { get { return isInDesignTool; } [SecurityCritical] set { isInDesignTool = value; } } internal static bool InternalIsInDesignMode { [CompilerGenerated] get { return k__BackingField; } [CompilerGenerated] set { k__BackingField = value; } } 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1030052.html

(0)
上一篇 2022年1月13日
下一篇 2022年1月13日

精彩推荐