How can I set a breakpoint and have the code stop on a line inside an AttachedCommand?
-
07-07-2019 - |
Question
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?
Solution
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"
OTHER TIPS
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());
}
};