title: WPF user control running storyboard against parent window object
body: <p>I have a UserControl contained within a parent window in WPF. The usercontrol contains a button that when pressed, needs to call back to the parent window and start a storyboard animation to set the opacity of the UserControl to 0, while setting the opacity of a different UserControl to 1.</p>
  
  <p>So effectively there is a button within my usercontrol that hides the containing usercontrol and switches to another one being visible.</p>
  
  <p>If the button is in the main window, it is easy as the first user control has an x:Name of leftpanel and the second is called leftpanelexpanded.</p>
  
  <pre><code>&lt;DoubleAnimation Storyboard.TargetName="Leftpanel" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="0"/&gt;
  &lt;DoubleAnimation Storyboard.TargetName="Leftpanelexpanded" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="1"/&gt;
  </code></pre>
  
  <p>But with the button in the user control, I can't figure out how to have this animation target the "leftpanel" and "leftpanelexpanded" usercontrol objects. I have tried RelativeSource but I can only get a handle to the parent window this way, I cant get a handle to the user control contained within the parent window.</p>
  
  <p>How can I do this?</p>