title: WPF: Get all children of a window and assign the same KeyDown event to them
body: <p>I'm using WPF to create a window with some controls of all kinds (buttons, textboxes, ...) in it.
  Now I'm trying to assign one KeyDown event to all controls when the window has finished loading.
  Unfortunately, I can't assign the event to the children of the window.</p>
  
  <pre><code>private void OnWindowLoaded(object sender, RoutedEventArgs e)
  {
       for (var i = 0; i &lt; VisualTreeHelper.GetChildrenCount(this); i++)
       {
           VisualTreeHelper.GetChild(this, i).KeyDown += Common_KeyDownEvent; // doesn't work
  
       }
  }
  
  private void Common_KeyDownEvent(object sender, System.Windows.Input.KeyEventArgs e)
  {
  
          if (e.Key == Key.Left)
          {
              // Do stuff
          }
          if (e.Key == Key.Right)
          {
             // Do other stuff               
          }
  }
  </code></pre>
  
  <p><em>Error:</em> <strong>'System.Windows.DependencyObject'</strong> does not contain a 
      definition  for 'KeyDown' and no extension method 'KeyDown' accepting 
      a first argument of type 'System.Windows.DependencyObject' could be found 
      (are you missing a using directive or an assembly reference?)</p>