title: WPF - how to handle mouse events outside component which raised that event?
body: <p>Context:</p>
  
  <p>There's an application where you draw things on canvas. Where user clicks there's a black dot, for example. But handling that events raised by canvas in event handlers in main window code is just ugly for me. So I wrote a class which methods mirror canvas mouse events and I call those methods inside event handler. </p>
  
  <pre><code>public partial class Window1 : Window
  {
      DrawingTool drawTool = new DrawingTool();
      public Window1()
      {
          InitializeComponent();            
      }
  
      private void drawingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
      {
          drawTool.OnMouseLeftButtonDown(e);
      }
  }
  </code></pre>
  
  <p>Nice, but I want more...</p>
  
  <p>Question:</p>
  
  <p>Is it possible to handle events raised by canvas in my DrawingTool class directly without having defined canvas event handlers. I'd like to keep my Window1 code clean and focused on window stuff and move events handling completely into my classes. </p>
  
  <p>I thought about deriving DrawingTool from FrameworkElement, override OnRender and draw it transparently over the canvas so user's click seemed to be made on canvas but in fact would be raised in DrawingTool and handled internally. This approach works with drawing functionality (after drawing is done drawn object is added to canvas children and removed from DrawingTool children) but when it comes to selection mode or others there are problems with hit testing of elements for example.</p>
  
  <p>So, I'll be grateful for any suggestion how to solve my problem or explanation why this is a stupid idea at all :)</p>