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.
So effectively there is a button within my usercontrol that hides the containing usercontrol and switches to another one being visible.
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.
<DoubleAnimation Storyboard.TargetName="Leftpanel" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="0"/>
<DoubleAnimation Storyboard.TargetName="Leftpanelexpanded" Storyboard.TargetProperty="Opacity" Duration="0:0:0.2" To="1"/>
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.
How can I do this?