我有故事板,而不是我想从后面的代码中应用一个按钮。我的故事板是在 view.cs 类中定义的,像这样..
private const string ANIMATION_FOCUSREGIONTEXT =
@"<Storyboard xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
<DoubleAnimation Duration=""0:0:0.25"" To=""0"" RepeatBehavior=""Forever"" Storyboard.TargetProperty=""(UIElement.Opacity)"">
<DoubleAnimation.EasingFunction>
<ExponentialEase EasingMode=""EaseIn"" Exponent=""3"" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>";
private Storyboard _focusregionStoryborad = XamlReader.Load(ANIMATION_FOCUSREGIONTEXT) as Storyboard;
当我尝试这个..
Button asd = new Button();
asd.Width = 100;
asd.Visibility = Visibility.Visible;
asd.Background = new SolidColorBrush(Colors.Red);
videoRectangle.Children.Add(asd);
Storyboard.SetTargetName(_focusregionStoryborad, "asd");
_focusregionStoryborad.Completed += _focusregionStoryborad_Completed;
_focusregionStoryborad.Begin(); // error
异常System.InvalidOperationException出现在这一行
_focusregionStoryborad.Begin();
我错过了什么..任何帮助表示赞赏..