1

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

<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 内的一行上?

4

2 回答 2

1

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

  • 工具 -> 选项 -> 调试 -> 常规
  • 取消选中“仅启用我的代码”
于 2009-09-14T14:28:50.713 回答
0

答案是我无意中在事件处理程序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());
    }
};
于 2009-09-14T14:57:35.070 回答