あなたは単にこのようなことをすることができます。あなたが投稿したリンクのソリューションに基づいています。あなたがMVVM
を使用している場合
public bool IsReleaseBuild
{
get { return MyStaticClass.IsAssemblyDebugBuild(Assembly.GetExecutingAssembly()); }
}
単にあなたのBaseClass
にProperty
を入れて、それがすべてView/ViewModels
が使用する可能性があります。
このように見える可能性があります。
public class BaseViewModel : ObservableObject
{
public Boolean IsReleaseBuild
{
get
{
...
}
}
}
私は自分のアプリケーションがVisual Studio Design Mode
に現在あるかどうかを把握する似たような操作を行います。添付プロパティについて
public class BaseViewModel : ObservableObject
{
private static Nullable<Boolean> _isInDesignMode;
public Boolean IsInDesignMode
{
get
{
if (!_isInDesignMode.HasValue)
{
DependencyProperty property = DesignerProperties.IsInDesignModeProperty;
_isInDesignMode
= (bool)DependencyPropertyDescriptor
.FromProperty(property, typeof(FrameworkElement))
.Metadata.DefaultValue;
}
return _isInDesignMode.Value;
}
}
}