ポータブル クラス ライブラリを使用して、独自の MVVM フレームワークのプラットフォームごとのアセンブリを削減しようとしています。
だから私は現在このコードを持っています(@lbugnion MVVMLightに触発されました)
public static bool IsInDesignModeStatic
{
get
{
if (!_isInDesignMode.HasValue)
{
#if シルバーライト
_isInDesignMode = DesignerProperties.IsInDesignTool;
#そうしないと
var prop = DesignerProperties.IsInDesignModeProperty;
_isInDesignMode
= (bool)DependencyPropertyDescriptor
.FromProperty(prop, typeof(FrameworkElement))
.Metadata.DefaultValue;
// Just to be sure
if (!_isInDesignMode.Value
&& Process.GetCurrentProcess().ProcessName.StartsWith("devenv", StringComparison.Ordinal))
{
_isInDesignMode = true;
}
#endif
}
return _isInDesignMode.Value;
}
}
}
しかし、これを PCL 内で使用しようとすると、DesignerProperties や FrameworkElement などが認識されません。どうすればこれを克服できますか?
ありがとう!