title: Can/Should MouseEnter event bubble?
body: <p>Is it possible under any circumstances to get MouseEnter event bubbling? </p>
  
  <p>MSDN says it's an attached event with Direct routing strategy, which technically excludes such possibility. I've a fairly complex control (in essence a hierarchy consisting of grids, stackpanels and content controls). I seem to get MouseEnter event propagated from bottom up, here's the debug dump taken from OnMouseEnter handler (I've the same custom control included at different levels of the hierarchy, which handles MouseEnter, so I have a central place for listening that event):</p>
  
  <p>In: parent:s7b, timestamp:37989609</p>
  
  <p>In: parent:s2, timestamp:37989609</p>
  
  <p>In: parent:Root, timestamp:37989609</p>
  
  <p>s7b, s2 and Root are FrameworkElement names and timestamp is e.Timestamp from MosueEnter event. </p>
  
  <p>Provided that the Routing Strategy is Direct, how does WPF decide on event originator? Does it traverse the visual tree until the first FrameworkElement with attached MouseEnter event is found?</p>
  
  <p>While I'm working on a minimalistic repro set for the problem, could anyone suggest what could cause the behaviour?</p>
  
  <hr>
  
  <p>And here's the repro:</p>
  
  <ol>
  <li>Create two custom controls, one is a contant control, another is event receiver.</li>
  </ol>
  
  <p>1.1. MyContentControl</p>
  
  <p>Code:</p>
  
  <pre><code>    public class MyContentControl : ContentControl
      {
          static MyContentControl()
          {
              DefaultStyleKeyProperty.OverrideMetadata(typeof(MyContentControl), 
                  new FrameworkPropertyMetadata(typeof(MyContentControl)));
          }
  
          protected override void OnMouseEnter(MouseEventArgs e)
          {
              if (e.Source == e.OriginalSource
                  &amp;&amp; e.Source is MyContentControl)
              {
                  Debug.Write(string.Format("mouseenter:{0}, timestamp:{1}\n",
                      (e.Source as MyContentControl).Name,
                      e.Timestamp));
              }
  
              base.OnMouseEnter(e);
          }
      }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type local:MyContentControl}"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type local:MyContentControl}"&gt;
                      &lt;StackPanel Orientation="Horizontal"&gt;
                          &lt;local:MouseEventReceiver /&gt;
                          &lt;ContentPresenter /&gt;
                      &lt;/StackPanel&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>1.2 MouseEventReceiver</p>
  
  <p>Code:</p>
  
  <pre><code>public class MouseEventReceiver : Control
  {
      static MouseEventReceiver()
      {
          DefaultStyleKeyProperty.OverrideMetadata(typeof(MouseEventReceiver), 
              new FrameworkPropertyMetadata(typeof(MouseEventReceiver)));
      }
  }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type local:MouseEventReceiver}"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate&gt;
                      &lt;Grid Background="LightGray" Width="20" Height="20" Margin="5"&gt;&lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <ol>
  <li>Finally the markup of my test harness:</li>
  </ol>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="MouseTricks.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:local="clr-namespace:MouseTricks"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;local:MyContentControl x:Name="c1"&gt;
              &lt;local:MyContentControl x:Name="c2"&gt;
                  &lt;local:MyContentControl x:Name="c3" /&gt;
              &lt;/local:MyContentControl&gt;
          &lt;/local:MyContentControl&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <hr>
  
  <p>In order to reproduce the problem just hover over the right most gray square and watch the Debug Output window, you'll see three entries in there, while I'm expecting just one.</p>
  
  <p>Cheers.</p>