tags:

views:

53

answers:

1

I have this control (WPF) that uses a CommandBinding and it gets registered like this:

CommandBinding binding = new CommandBinding(ApplicationCommands.Delete, OnDeleteExecuted, CanExecuteDelete);
CommandManager.RegisterClassCommandBinding(typeof(MyObject), binding);

So, when I unload the control, I want to clear this binding. How would I go about that?

Thanks!

+1  A: 

BindingOperations.ClearBinding

Charlie
Would BindingOperations.ClearAllBindings(this); be better for this case?
Carlo
If you're in the context of the control, then yes. You could instantly clear all the bindings for that control.
Charlie
Sounds good. Thank you.
Carlo