如何设置断点并使代码停止在 AttachedCommand 内的一行上?
-
07-07-2019 - |
题
在我的 XAML 我有这个 命令 (这是我从 http://marlongrech.wordpress.com):
<TextBlock Text="Edit Test Customer">
<Commands:CommandBehaviorCollection.Behaviors>
<Commands:BehaviorBinding Event="MouseLeftButtonDown"
Command="{Binding ClickEditTestCustomer}"/>
</Commands:CommandBehaviorCollection.Behaviors>
</TextBlock>
然后在命令中,如果我设置 断点 在 - 的里面 执行委托 代码,例如在“layoutManger...”行上,即使执行了该代码,它也不会在断点处停止(我看到了我的观点):
ClickEditTestCustomer = new SimpleCommand
{
ExecuteDelegate = parameterValue =>
{
LayoutManager layoutManager = container.Resolve<LayoutManager>();
layoutManager.DisplayViewAsPane("EditCustomer", "Edit Customer", new EditCustomerView());
}
};
如何设置断点并使代码停止在 AttachedCommand 内的一行上?
解决方案
这应该没有任何问题。如果您 100% 确定 LayoutManager 行实际上正在运行,那么可能是我的代码 (JMC) 的调试功能有问题。尝试禁用 JMC 并再次运行场景
- 工具->选项->调试->常规
- 取消选中“仅启用我的代码”
其他提示
答案是我无意中复制了两次中的事件处理程序 ClickEditTestCustomer ,这出人意料地没有产生错误并且只是静静地执行了第二个实例:
ClickEditTestCustomer = new SimpleCommand
{
ExecuteDelegate = parameterValue =>
{
LayoutManager layoutManager = container.Resolve<LayoutManager>();
layoutManager.DisplayViewAsPane("EditCustomer", "Edit Customer", new EditCustomerView());
}
};
ClickEditTestCustomer = new SimpleCommand
{
ExecuteDelegate = parameterValue =>
{
LayoutManager layoutManager = container.Resolve<LayoutManager>();
layoutManager.DisplayViewAsPane("EditCustomer", "Edit Customer", new EditCustomerView());
}
};
不隶属于 StackOverflow