如何在设计模式下调试 WPF 用户控件? [英] How do you debug a WPF user control in design mode?

查看:11
本文介绍了如何在设计模式下调试 WPF 用户控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个包含标签的 wpf 用户控件.标签的前台设置会根据检查多个条件的某些代码而更改.我的控件中的标签在设计时显示错误的颜色,但我无法弄清楚如何在设计时调试我的用户控件,以便我可以让它捕获断点(从而找出我的逻辑有缺陷的地方).控件上的颜色在运行时是正确的,只是在设计时显示不正确.

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.

推荐答案

以下是在设计时调试控件的步骤:

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

  • 启动第二个 Visual Studio 实例
  • 从调试"菜单附加到第一个实例
  • 在第二种情况下,打开控件的源代码
  • 在适当的位置设置断点
  • 在第一个 VS 实例中,重新加载设计器

请注意,此技术不限于控件;您还可以使用它来调试 VS 扩展,或在 Visual Studio 中执行的任何内容.

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.

这篇关于如何在设计模式下调试 WPF 用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆