title: Android's Ripple Effect in WPF
body: <p>I love Androids new animation where you touch a control (listviewitem, button etc etc) and it does a neat animation like this:</p>
  
  <p><img src="https://i.stack.imgur.com/esYlw.gif" alt="enter image description here"></p>
  
  <p>I'm wondering how this can be implemented in a nice way globally for all the 'clickable' controls in WPF.</p>
  
  <hr>
  
  <p>What I specifically need help with is how the circles should be created on the control. The only thing I've thought of was to create own user-controls for each other control (buttons, radiobuttons, etc) where I have a parent for the ellipse as well as the original control itself.</p>
  
  <pre><code>&lt;UserControl&gt;
     &lt;Grid MouseLeftButtonDown="handler"&gt;
        &lt;Button/&gt; &lt;--- this would be the button which you normally would place
     &lt;/Grid &gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>And in the <code>handler-method</code> then create an ellipse on the point <code>e.GetPosition(handler)</code> using the margin-properties and later animate it. This solution <strong>would</strong> work. But it would be a hassle to do this for every control I would want the ripple effect on. Basically something like this:</p>
  
  <pre><code>void handler(object sender, MouseButtonEventArgs e)
  {
     Grid parent = (Grid)sender;
     Ellipse ellipse = new Ellipse();
     ellipse.Height = 10; // would be animated
     ellipse.Width = 10; // would be animated
  
     Point p = e.GetPosition(parent);
  
     ellipse.Margin = new Thickness(p.X, p.Y, 0, 0);
  
     parent.Children.Add(ellipse);
  
     // do the animation parts to later remove the ellipse
  }
  </code></pre>
  
  <p>Is there a cleaner, more expandable way to place ellipses on my controls other than the way I earlier demonstrated since not all controls support having children?</p>