1

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?

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
  • 2
    That's odd, you can normally set a breakpoint on the first line in the delegate method and it'll execute. Is this new, or has it always been this way for you? Tried restarting VS? –  Sep 14 '09 at 13:56

2 Answers2

1

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"
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
0

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());
    }
};
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047