如何设置断点并使代码停止在 AttachedCommand 内的一行上?

发布于 2024-08-04 12:08:03 字数 1093 浏览 6 评论 0原文

在我的XAML中,我有这个命令(这是我从http://marlongrech.wordpress.com):

<TextBlock Text="Edit Test Customer">
    <Commands:CommandBehaviorCollection.Behaviors>
        <Commands:BehaviorBinding Event="MouseLeftButtonDown" 
                                   Command="{Binding ClickEditTestCustomer}"/>
    </Commands:CommandBehaviorCollection.Behaviors>
</TextBlock>

然后在命令中,如果我在里面设置一个断点 ExecuteDelegate 代码,例如在“layoutManger...”行上,即使执行了该代码,它也不会在断点处停止(我看到了我的视图):

ClickEditTestCustomer = new SimpleCommand
{
    ExecuteDelegate = parameterValue =>
    {
        LayoutManager layoutManager = container.Resolve<LayoutManager>();
        layoutManager.DisplayViewAsPane("EditCustomer", "Edit Customer", new EditCustomerView());
    }
};

我该如何设置断点并使代码停止在 AttachedCommand 内的一行上?

In my XAML I have this command (which is an AttachedCommand which I got from http://marlongrech.wordpress.com):

<TextBlock Text="Edit Test Customer">
    <Commands:CommandBehaviorCollection.Behaviors>
        <Commands:BehaviorBinding Event="MouseLeftButtonDown" 
                                   Command="{Binding ClickEditTestCustomer}"/>
    </Commands:CommandBehaviorCollection.Behaviors>
</TextBlock>

Then in the command, if I set a breakpoint inside the ExecuteDelegate code, e.g. on "the "layoutManger..." line, it doesn't stop on the breakpoint even though that code is executed (I see my view):

ClickEditTestCustomer = new SimpleCommand
{
    ExecuteDelegate = parameterValue =>
    {
        LayoutManager layoutManager = container.Resolve<LayoutManager>();
        layoutManager.DisplayViewAsPane("EditCustomer", "Edit Customer", new EditCustomerView());
    }
};

How can I set a breakpoint and have the code stop on a line inside an AttachedCommand?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北音执念 2024-08-11 12:08:03

这应该没有任何问题。如果您 100% 确定 LayoutManager 行实际上正在运行,那么可能是我的代码 (JMC) 的调试功能有问题。尝试禁用 JMC 并再次运行场景

  • 工具 ->选项->调试->一般
  • 取消选中“仅启用我的代码”

This should work without any problem. If you are 100% sure that the LayoutManager line is actually running then it may be a problem with the debugging feature just my code (JMC). Try disabling JMC and running the scenario again

  • Tools -> Option -> Debugging -> General
  • Uncheck "Enable Just My Code"
但可醉心 2024-08-11 12:08:03

答案是我在两次中无意中复制了事件处理程序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());
    }
};

The answer was that I had inadvertently copied in the event handler ClickEditTestCustomer in twice, which surprisingly didn't produce an error and quietly executed only the second instance:

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());
    }
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文