MVVM Light IsInDesignMode property not working

微笑、不失礼 提交于 2019-12-10 15:18:00

问题


I'm having an issue where the property IsInDesignMode is not returning the expected value of true when running the solution in VS or Blend. My environment consists of Win Server 2008 R2, VS2010 Pro, Blend 4 and MVVM Light V3. I run my Silverlight 4 solution in Debug mode from VS and Blend, and IsInDesignMode is always false. Am I missing a setting? Is there a reason why it may not be picking up the environment? Thanks in advance.

-Greg


回答1:


It should work properly. The only place where I know that IsInDesignMode returns a wrong value is when using it to build code that runs within Visual Studio, such as VS plug-ins. This is an issue that is very difficult to solve. It doesn't sound like it is what you are doing, though...

Do you have a repro that I can test? Alternatively, could you download the MVVM Light code and debug this?

Thanks, Laurent




回答2:


Kill all XDesProc.exe processes in task manager and then click "restart the designer" in visual studio.
This always fixes it for me.




回答3:


Did you try if (IsInDesignModeStatic){ ... } instead?




回答4:


I run my Silverlight 4 solution in Debug mode from VS and Blend, and IsInDesignMode is always false. Am I missing a setting?

The IsInDesignMode flags should only be true when running inside the designer in either Visual Studio or Blend. Once you run the application in the debugger, the values should be false. This feature should be used to design your Views inside the designer without needing to run the application.




回答5:


I ran into this myself in Visual Studio 2013. I also had the project open in Blend at the same time. I closed VS2013, closed Blend, reopened in VS 2013, and once again all was right with the world (IsInDesign returned TRUE).



来源:https://stackoverflow.com/questions/3303024/mvvm-light-isindesignmode-property-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!