How do you debug a WPF user control in design mode?(如何在设计模式下调试 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 用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在设计模式下调试 WPF 用户控件?
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
