views:

14

answers:

1

Hi all,

I've used WPF for quite some time now, but I've never looked serious into animation. I'm trying to achieve the following, but until now, not successful.

I have a class called "Property". This class has the ability to fire an event:

public class Property
{
    // ...

    public event System.Windows.RoutedEventHandler Attract;

    // ...
};

The properties are shown on the screen. Sometimes I need to attract the user's attention to a certain property. I want to fire the "Attract" event on the property. Then, from XAML start an animation.

I would expect something like this:

<Storyboard x:Key="blinkingAnimation">
    <DoubleAnimation From="0" To="1" Duration="0:0:5" RepeatBehavior="3x" AutoReverse="True" Storyboard.TargetProperty="(UIElement.Opacity)" />
</Storyboard>

<DataTemplate x:Key="PropertyTemplate" DataType="{x:Type GridViewColumn}">
    <TextBox>
        <TextBox.Triggers>
            <EventTrigger RoutedEvent="Attract">
                <EventTrigger.Actions>
                    <BeginStoryboard Storyboard="{StaticResource blinkingAnimation}"/>
                </EventTrigger.Actions>
            </EventTrigger>
        </c:NumericTextBox.Triggers>
    </TextBox>
</DataTemplate>

Is this the proper way to do it? At runtime, the compiler fails to resolve the "Attract" event. What am I doing wrong?

A: 

That's not the proper way to declare a routed event. See msdn (http://msdn.microsoft.com/en-us/library/system.windows.routedevent.aspx) for reference.

mostlytech
Thanks. Solved it acutally using this link: http://www.hardcodet.net/2009/05/trigger-wpf-animations-through-attached-events
Robbert Dam