How do you debug a WPF user control in design mode?

风流意气都作罢 提交于 2019-12-01 01:17:44

问题


I have a wpf user control I created that contains a label. The label's foreground setting changes based on some code that checks a number of conditions. The label in my control is displaying the wrong color at design time but I cannot figure out how to debug my user control at design time so that I can have it catch breakpoints (and thus figure out where my logic is flawed). The color on the control is correct at run-time, it is only at design time that it is displayed incorrectly.


回答1:


Here are the steps to debug a control at design time:

  • Start a second instance of Visual Studio
  • Attach to the first instance from the Debug menu
  • In the second instance, open the source code of your control
  • Set breakpoints at appropriate locations
  • In the first VS instance, reload the designer

Note that this technique isn't limited to controls; you can also use it to debug VS extensions, or anything that executes within Visual Studio.



来源:https://stackoverflow.com/questions/27475247/how-do-you-debug-a-wpf-user-control-in-design-mode

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