如何停止ViewModel代码在设计器中运行? [英] How do I stop my ViewModel code from running in the designer?
本文介绍了如何停止ViewModel代码在设计器中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用MVVM模式开发一个联网的WPF应用程序,它似乎正在运行并连接到设计器中的服务器.
I'm developing a networked WPF application with the MVVM pattern and it seems that it's running and connecting to servers in the designer.
我知道IsInDesignMode属性,但是我不确定如何在ViewModel中访问它.
I know about the IsInDesignMode property, but I'm not sure how to access it in a ViewModel.
推荐答案
DependencyObject dep = new DependencyObject();
if (DesignerProperties.GetIsInDesignMode(dep))
{
...
}
这篇关于如何停止ViewModel代码在设计器中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文