我搜索DesignMode
自定義WPF UserControl上的布爾值... 如何正確我推動它嗎?WPF UserControl DesignMode屬性(託管在WinForm上)
我有一個WinForm託管WPF控件。我看到了「DesignerProperties」類不會在這種情況下工作。
我在拋出異常的設計模式構造一些邏輯,想跳過的代碼,因爲我不到貨看到一個表格與我在設計用戶控件。
我試圖
private static bool? _isInDesignMode;
/// <summary>
/// Gets a value indicating whether the control is in design mode
/// (running in Blend or Visual Studio).
/// </summary>
public static bool IsInDesignModeStatic
{
get
{
if (!_isInDesignMode.HasValue)
{
#if SILVERLIGHT
_isInDesignMode = DesignerProperties.IsInDesignTool;
#else
var prop = DesignerProperties.IsInDesignModeProperty;
_isInDesignMode
= (bool)DependencyPropertyDescriptor
.FromProperty(prop, typeof(FrameworkElement))
.Metadata.DefaultValue;
#endif
}
return _isInDesignMode.Value;
}
}
但這並不工作:((我看到設計師在例外 「封殺」 與IsInDesignModeStatic行代碼...
不起作用,設計師給了我一個錯誤堆棧跟蹤從裏面如果(!DesignerProperties ....) – serhio 2010-11-08 12:42:57
我應該此話,我有一個WinForm和WPF控件裏面,這個代碼爲WPF控件無法正常工作,當我打開的Winform – serhio 2010-11-08 12:47:09