title: 'System.StackOverflowException' occurred in PresentationCore.dll
body: <p>I have a WPF UserControl in which I try to implement the <strong>custom</strong> MouseClick (because <em>there is no <code>MouseClick</code> event on a WPF (User)Control</em>) event. </p>
  
  <p>I got the following:</p>
  
  <p><img src="https://i.stack.imgur.com/3zW8p.jpg" alt="alt text"></p>
  
  <p>Some code: </p>
  
  <pre><code>/// &lt;summary&gt;
  /// Occurs when users left clicks the MyControl.
  /// &lt;/summary&gt;
  public event MouseButtonEventHandler MouseClick { add { AddHandler(MouseClickEvent, value); } remove { RemoveHandler(MouseClickEvent, value); } }
  
      protected virtual void OnMouseClick(MouseButtonEventArgs e)
      {
          base.RaiseEvent(e);
          //this.RaiseEvent(new RoutedEventArgs(MouseClickEvent, this));
      }
  
      protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
      {
          base.OnMouseLeftButtonUp(e);
          if (!this.movedAfterMouseDown)
          {
              OnMouseClick(e);
          }
          this.gotLeftButtonDown = false;
          this.movedAfterMouseDown = false;
      }
  </code></pre>
  
  <p>So, where is the problem?</p>
  
  <h1>UPDATE 1</h1>
  
  <pre><code>protected virtual void OnMouseClick(MouseButtonEventArgs e)
  {
      //base.RaiseEvent(e);
      MouseButtonEventArgs args = new MouseButtonEventArgs(e.MouseDevice, e.Timestamp, e.ChangedButton);
      this.RaiseEvent(args);
  }
  </code></pre>
  
  <p>Value cannot be null.
  Parameter name: routedEvent</p>
  
  <p><img src="https://i.stack.imgur.com/BCSlk.jpg" alt="alt text"></p>
  
  <h1>UPDATE 2</h1>
  
  <p>An other custom event I implemented successfully (work without problems) - <code>SelectedChanged</code>:</p>
  
  <pre><code>static void OnIsSelectedChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
  {
      var s = (MyControl)source;
  
      s.RaiseEvent(new RoutedEventArgs(SelectedChangedEvent, s));
  }
  </code></pre>
  
  <h1>UPDATE 3</h1>
  
  <p>System.Windows.Controls.Control's OnPreviewMouseDoubleClick implementation:</p>
  
  <pre><code>protected virtual void OnPreviewMouseDoubleClick(MouseButtonEventArgs e)
  {
      base.RaiseEvent(e);
  }
  </code></pre>
  
  <h1>Update 5 (for people in the tank)</h1>
  
  <pre><code>class Foo : FrameworkElement
  {
      event EasterCameEvent; // I named it MouseClick
  
      public DoSomething()
      {
          EasterCameArgs args= ...
  
          if (Date.Now = EasterDate)
              OnEasterCame(args)
      }
  
      protected virtual void OnEasterCame(EasterCameArgs e)
      {
          base.RaiseEvent(e);
      }
  }
  </code></pre>