How can I launch an event that has accessors like this :
public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } }
If it were a normal event I would launch it by:
CanExecuteChanged(sender, EventArgs..).
But here it doesn’t work – I can only do
CanExecuteChanged +=..
to attach a method do the event – but I can’t Launch it.
Also some documentation on the subject would be appreciated. Thanks.
EDIT The event is from class implementing ICommand in WPF. there’s nothing more to show :). And no – the CommandManager.RequerySuggested(this, EventArgs.Empty); doesn’t work.
EDIT2 Not sure what to say – Jon’s example should have worked yet even if the add method is called correctly – when I try to call the event – it’s null :|. I probably will drop events with accessors.
That event is just subscribing to and unsubscribing from another event. If you want your subscribers (and only your subscribers – not separate ones to the other event) to be invoked, you’ll need to keep hold of your subscribers separately. For instance, you could change the code to something like: