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.
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)));
This code will fire your Command as DockPanel.Loaded event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With