Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty EventName in Interaction EventTrigger

Consider the following code:

<DockPanel>
    <i:Interaction.Triggers>
        <i:EventTrigger>
            <i:InvokeCommandAction Command="{Binding Path=MyCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    …

As EventTrigger does not have EventName property set, what events will it handle? It is handling something definitely because I see that this command is executed.

like image 868
bpiec Avatar asked Feb 10 '26 10:02

bpiec


2 Answers

Your Command gets called when the Loaded event occurs.

If we look at the source code of the EventTrigger class, we can see that the DependencyProperty EventNameProperty has Loaded as its default value.

public static readonly DependencyProperty EventNameProperty = DependencyProperty.Register("EventName", typeof (string), typeof (EventTrigger), (PropertyMetadata) new FrameworkPropertyMetadata((object) "Loaded", new PropertyChangedCallback(EventTrigger.OnEventNameChanged)));
like image 108
Tom C. Avatar answered Feb 15 '26 11:02

Tom C.


This code will fire your Command as DockPanel.Loaded event.

like image 41
sTrenat Avatar answered Feb 15 '26 11:02

sTrenat