However, I'm trying to do the same thing programmatically, so that I can determine at runtime what the new height should be when the user clicks on a panel. I implemented the following EventHandler, but it doesn't work (the Panel heights do not change).
private void Panel1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
DoubleAnimation oMenuAnimation = new DoubleAnimation();
oMenuAnimation.To =646;
oMenuAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 500));
oMenuAnimation.AccelerationRatio = .6;
oMenuAnimation.DecelerationRatio = .4;
Storyboard s = new Storyboard();
Storyboard.SetTargetProperty(oMenuAnimation, new PropertyPath("Height"));
Storyboard.SetTarget(oMenuAnimation,Panel1);
Storyboard.SetTargetName(oMenuAnimation, "Panel1");
s.Children.Add(oMenuAnimation);
DoubleAnimation oMenuAnimation2 = new DoubleAnimation();
oMenuAnimation2.To = 26;
oMenuAnimation2.Duration = new Duration(new TimeSpan(0, 0, 0, 500));
oMenuAnimation2.AccelerationRatio = .6;
oMenuAnimation2.DecelerationRatio = .4;
Storyboard.SetTargetProperty(oMenuAnimation2, new PropertyPath("Height"));
Storyboard.SetTarget(oMenuAnimation2, Panel2);
s.Children.Add(oMenuAnimation2);
s.Begin();
}
Does anyone know what I'm doing wrong?
Mageshwaran RPosted Nov 24, 2019, 9:16 AM
Manikandan MurugesanPosted Jun 24, 2017, 9:10 PM