In my Application.Resources , I have the following Storyboard .
<Application.Resources> <Storyboard x:Key="FadeOutAnimation"> <DoubleAnimation From="1" To="0" Duration="0:0:0.25" Storyboard.TargetProperty="Opacity" AutoReverse="False" /> </Storyboard> </Application.Resources>
In encoding, I use this to extinguish some TextBlock when the user clicks on them.
// Get the storyboard from application resources Storyboard sb = (Storyboard)App.Current.Resources["FadeOutAnimation"]; // Setup the animation target for fade out Storyboard.SetTarget( sb.Children.ElementAt( 0 ) as DoubleAnimation, myTextBlock ); // Set the animation completed handler sb.Completed += ( s, e1 ) => { // Stop the Storyboard sb.Stop(); // Hide the TextBlock myTextBlock.Visibility = Visibility.Collapsed; }; // Start the Storyboard sb.begin();
The question is, does myTextBlock need to be โ myTextBlock โ from the DoubleAnimation target DoubleAnimation ?
If so, how do I do this?
The reason I ask, I am worried that the link to the TextBlock hangs until this storyboard is used again.
Thank you for your help!
windows-phone-7 wpf silverlight
Praetorian
source share