我相信您正在寻找具有DependencyObject的GetIsInDesignMode。
就是
// 'this' is your UI elementDesignerProperties.GetIsInDesignMode(this);
编辑: 使用Silverlight /
WP7时,应使用,
IsInDesignTool因为
GetIsInDesignMode有时在Visual
Studio中可能返回false:
DesignerProperties.IsInDesignTool
编辑: 最后,出于完整性考虑,WinRT / Metro / Windows
Store应用程序中的等效项是
DesignModeEnabled:
Windows.ApplicationModel.DesignMode.DesignModeEnabled



