title: What is the difference betwen handling an event and extending a class and overriding the related protect On... method?
body: <p>In the .NET <code>System.Windows</code> assembly, classes often define events and raise them throughout the lifetime of the object. For example, the <code>UIElement</code> class defines the <code>KeyUp</code> event, which is 'alias to the Keyboard.KeyUp event':</p>
  
  <pre><code>public event KeyEventHandler KeyUp;
  </code></pre>
  
  <p>However, it also declares the <code>protected OnKeyUp</code> method, that is called upon the event being fired:</p>
  
  <pre><code>protected virtual void OnKeyUp(KeyEventArgs e);
  </code></pre>
  
  <p>There is a protected method for each event, as far as I can see. As these methods are protected, they can only be called from a class that is extending the <code>UIElement</code> class. Let's imagine that I have such an extending class.</p>
  
  <p>My question is, given my class that extends the <code>UIElement</code> class, what is the difference between overriding the protected method and handling the relevant event? Is there a difference at all? Is there any benefit from using the protected methods over handling the events?</p>