views:

28

answers:

2

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?

+1  A: 

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
that wasn't the solution but +1 for interesting to know
Edward Tanguay
A: 

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