3 回答

TA貢獻1995條經(jīng)驗 獲得超2個贊
我相信您正在尋找具有DependencyObject的GetIsInDesignMode。
就是
// 'this' is your UI element
DesignerProperties.GetIsInDesignMode(this);
編輯:使用Silverlight / WP7時,應(yīng)使用,IsInDesignTool因為GetIsInDesignMode有時在Visual Studio中可能返回false:
DesignerProperties.IsInDesignTool
編輯:最后,出于完整性考慮,WinRT / Metro / Windows Store應(yīng)用程序中的等效項是DesignModeEnabled:
Windows.ApplicationModel.DesignMode.DesignModeEnabled

TA貢獻1789條經(jīng)驗 獲得超10個贊
您可以執(zhí)行以下操作:
DesignerProperties.GetIsInDesignMode(new DependencyObject());

TA貢獻1826條經(jīng)驗 獲得超6個贊
public static bool InDesignMode()
{
return !(Application.Current is App);
}
可在任何地方工作。我用它來阻止數(shù)據(jù)綁定視頻在設(shè)計器中播放。
- 3 回答
- 0 關(guān)注
- 832 瀏覽
添加回答
舉報