Running Animation From Code Behind
i have the storyboard than i wanted to apply on a button from code behind.
my storyboard is defined in view.cs class like this..
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;
when i tried this..
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
the Exception System.InvalidOperationException come on this line
_focusregionStoryborad.Begin();
am i missing something ..any help is appreciated..
No comments:
Post a Comment