Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Trigger Storyboard from c# code

Closed Thread
 
Thread Tools Display Modes
Old 08-14-2007   #1 (permalink)
timmy@trashymail.com
Guest


 

Trigger Storyboard from c# code

Hello everybody,

I'm currently using a template for a button that triggers a storyboard
animation when moving the mouse over the button. The template looks
basically like this:

....
<ControlTemplate x:Key="GlassButton" TargetType="{x:Type Button}">
<ControlTemplate.Resources>
<Storyboard x:Key="Timeline1" x:Name="Timeline1">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="glow"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Border Opacity="0" HorizontalAlignment="Stretch" x:Name="glow"
Width="Auto" Grid.RowSpan="2" CornerRadius="4,4,4,4">
....

Now I want to trigger the storyboard animation from the c# code as
well. I tried something like

Object o = myButton.FindResource("Timeline1");
myButton.BeginStoryboard((Storyboard)o);

however, this throws an InvalidOperationException pointing out that
"'glow' name cannot be found in the name scope of
'System.Windows.Controls.Button'".

What do I do wrong?

Thanks in advance

Timmy

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Trigger Data Binding to Method Runar Jordahl Avalon 5 10-17-2007 07:24 PM
How do you trigger MCE in Vista Ultimate? MrMikeH Vista music pictures video 1 01-19-2007 02:39 PM
trigger for IsFocused - not working? CosminB [BRT] Avalon 0 04-22-2006 02:00 AM
Can trigger work outside a style ? Philippe Lavoie Avalon 1 03-15-2006 10:21 PM
databinding trigger Arnaud Fontaine Avalon 4 01-31-2006 06:59 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50