index > Windows Presentation Foundation ("Avalon") > multiple animations within one EventTrigger

multiple animations within one EventTrigger

hi,

how can i realize animations on multiple rectangles within the same event. I want to define this within a style in my XAML. My idea is, if a certain event takes place, multiple animations on different rectangles will be started.

i tried the following:

<ControlTemplate.Triggers>

<EventTrigger RoutedEvent="Button.MouseEnter">

<EventTrigger.Actions>

<BeginStoryboard>

<Storyboard>

<ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="rect_Normal" Storyboard.TargetProperty="(Rectangle.Visibility)">

<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Hidden}" />

</ObjectAnimationUsingKeyFrames>

<ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="rect_Over" Storyboard.TargetProperty="(Rectangle.Visibility)">

<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />

</ObjectAnimationUsingKeyFrames>

</Storyboard>

</BeginStoryboard>

</EventTrigger.Actions>

</EventTrigger>

</ControlTemplate.Triggers>

It works all fine if i define just ONE "ObjectAnimationUsingKeyFrames", but with a second "ObjectAnimationUsingKeyFrames" the animations don't work anymore.

Any Ideas???

Thanks,

bkohler

bkohler
what you have should work, Can you give some details on what is not working?
lee d

Don't you need two keyframes for a keyframe animation?




What's in your toolbelt? http://www.codeplex.com/Wiki/View.aspx?ProjectName=wpftoolbelt
ivolved_Mike_Brown
No, one should do.
lee d
Ah...he's trying to get around that limit of not being able to set a property on a non-contained element in a Style Trigger.


What's in your toolbelt? http://www.codeplex.com/Wiki/View.aspx?ProjectName=wpftoolbelt
ivolved_Mike_Brown

Storyboard.TargetName is indeed not allowed inside Style.Trigger storyboard. However, the markup here is in a ControlTemplate.Trigger storyboard, which does allow targeting of named elements as long as the elements are within the ControlTemplate.

To diagnose further, we would need to see the rest of the ControlTemplate. Specifically, we need to see how the rectangles "rect_Normal" and "rect_Over" are defined, and their relationship to the rest of the control template.

It would also help to know what "doesn't work" means. If an exception is thrown, the exception message and call stack should provide useful information.




(From Microsoft Legal: This posting is provided "AS IS" with no warranties, and confers no rights.)
Roger Cheng - MSFT

guys,

i'm really sorry. it was my fault...

the code i posted works... unfortunately the second animation didn't change the appearance of my ui, so i thought it is not running... sometimes it would be really nice to able to debug xaml code...

thanks a lot for your hints,

bkohler

 

bkohler
reply 7

You can use google to search for other answers

 

More Articles

• Bug Fixes
• use UserControl
• Is it possible to create a seperation line in Listview?
• Relative Image Path
• Generic Sortable ListView
• Mousewheel Event in xaml
• gridview
• feature requests for WPF v2
• Question
• uploading powerpoint file on the server.
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• (not only MediaElement) VisualBrush Code
• How to populate a WPF TreeView node from
• Filter data between two comboBox(Master
• Apply 2 or more styles to an element
• How to use btn.RaiseEvent to fire button
• DesiredSize of Control is not set, even
• Writing reusable effects in XAML
• attaching events with a polyline
• Tool for determining KeySpline values
• Custom Popup Placement in control template
• How to add a column in a Listview dynami
• DoubleClick on FrameworkElement
• Storyboards and Threads Question
• XamlWriter : Does NameScope.RegisterName
• PageFunction Base Class

Hot Articles

• Is it possible to implement a GridView w
• Event for new Window
• Can i pass URL query strings from one xa
• Property trigger ExitActions
• Event happening twice
• Writing reusable effects in XAML
• how to pass URL query strings from one x
• XBAP's and firewalls
• Design and Generics
• file IO permission for XBAP
• WPF equivalent for windows forms button.
• Why can't I freeze BitmapImage ?
• scrolling contents in a stackpanel which
• ITypedList not supported in data binding?
• Canvas Callback without Background Set

Recommend Articles

• Auto for Height and Width in code
• Assigning the curved Border for the List
• Textblock/Label/Frame/RichTextBox/Whatev
• Clocks and timelines and storyboards wit
• SolidBrush and Resource Dictionaries
• error when hosting WPF control inside of
• WPF Query
• What dictates object the creation sequen
• Polygon.Points Binding TwoWay
• Bug when MouseLeave Event in ControlTemp
• How to apply Sorting in a List view cont
• FindItemWithText in ListviewItem?
• How to get reference of treeviewitem?
• How to bind a collection directly to a c
• Moving FrameworkElement using DoubleAnim