Usercontrol animation in C #

Right. I need some silly sample animation of Usercontrol WPF in C # under Canvas. I tried all the combinations for the Begin plot (??????); But he always gives an error. Any clues?

Storyboard story = new Storyboard(); DoubleAnimation dbWidth = new DoubleAnimation(); dbWidth.From = 0; dbWidth.To = 200; dbWidth.Duration = new Duration(TimeSpan.FromSeconds(.25)); DoubleAnimation dbHeight = new DoubleAnimation(); dbHeight.From = 0; dbHeight.To = 200; dbHeight.Duration = dbWidth.Duration; story.Children.Add(dbWidth); Storyboard.SetTargetName(dbWidth, PluginUControl.Name); Storyboard.SetTargetProperty(dbWidth, new PropertyPath(UserControl.WidthProperty)); story.Children.Add(dbHeight); Storyboard.SetTargetName(dbHeight, PluginUControl.Name); Storyboard.SetTargetProperty(dbHeight, new PropertyPath(UserControl.HeightProperty)); story.Begin(??????); 

UPDATE:

I also tried to do this

  story.Begin((MainWindow)App.Current.Windows[0]); 

I guessed that this is the same story. Begin (this); but without success ...

0
source share
1 answer

Dmitry Boyko:

I found guys solutions!

He must replace

 Storyboard.SetTargetName(dbWidth, PluginUControl.Name); 

from

 Storyboard.SetTarget(dbWidth, PluginUControl); 
0
source

Source: https://habr.com/ru/post/887193/


All Articles