Reputation: 10509
I want to process a Page_Loaded event of my View (PhoneApplicationPage
) in a view model. This used to be accomplished by the following:
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<Command:EventToCommand Command="{Binding LoadedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
This approach uses MVVM Light EventToCommand
.
But his approach no longer works and gives the following error:
A value of type 'EventToCommand' cannot be added to a collection or dictionary of type 'TriggerActionCollection'.
In WP7.1, what is the correct MVVM way to bind view's events to a view model's methods?
Upvotes: 2
Views: 543
Reputation: 39006
Try using InvokeCommandAction.
Update
Actually if you just want it to directly bind to the method you can also try CallMethodAction. ;)
Upvotes: 1