Search code examples
wpfanimationstoryboardeventtrigger

Can not find the EventTrigger.SourceName


<Canvas>
    <Button Name="b1" Content="Button"/>
    <Rectangle Name="Mr1" Fill="Black">
        <Rectangle.Triggers>
            <EventTrigger SourceName="b1" RoutedEvent="Button.Click">
                <BeginStoryboard>
                 <code.../>
                </BeginStoryboard>
            </EventTrigger>
        </Rectangle.Triggers>
    </Rectangle>
</Canvas>

Error: can not find the b1.

Please help me, thank you.


Solution

  • You can set this property to the name of any element within the scope of where the trigger collection (the collection that this Trigger is part of) is applied. This is typically a named element that is within the template that contains this Trigger.