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.
我有一个我创建的包含标签的wpf用户控件。标签的前景设置根据检查许多条件的某些代码而更改。我控制中的标签在设计时显示错误的颜色,但我无法弄清楚如何在设计时调试我的用户控件,以便我可以让它捕获断点(从而找出我的逻辑存在缺陷的地方)。控件上的颜色在运行时是正确的,只有在设计时它才会显示不正确。
1 个解决方案
#1
5
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
启动Visual Studio的第二个实例
从“调试”菜单附加到第一个实例
在第二个实例中,打开控件的源代码
在适当的位置设置断点
在第一个VS实例中,重新加载设计器
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.
注意,该技术不限于控制;您还可以使用它来调试VS扩展或在Visual Studio中执行的任何操作。
#1
5
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
启动Visual Studio的第二个实例
从“调试”菜单附加到第一个实例
在第二个实例中,打开控件的源代码
在适当的位置设置断点
在第一个VS实例中,重新加载设计器
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.
注意,该技术不限于控制;您还可以使用它来调试VS扩展或在Visual Studio中执行的任何操作。