Page 2 of 2

Re: How to send event from view to VM?

Posted: 12 Mar 2018, 04:42
by UE4
the Command can be set only once?

Re: How to send event from view to VM?

Posted: 12 Mar 2018, 23:08
by hcpizzi
Do you mean if you can have more than one Command bound to a given event?

Re: How to send event from view to VM?

Posted: 13 Mar 2018, 02:01
by UE4
My game logic will process TouchDown/TouchUp event, so I think there should be both two commands for MVVM, am I wrong?
At present, then EventToCommand can be used only once, so I implement a UserControl, and treat both TouchDown and TouchUp as ButtonAction event, but pass deffirent param, then convert to command and I can use one command send 2 actions.

Re: How to send event from view to VM?

Posted: 15 Mar 2018, 15:00
by hcpizzi
Hi,

Yes, you are right, that is a limitation of the EventToCommand class. We are working on an new system that will allow you to bind multiple events to commands, with a syntax like this:
<ListBox ...>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="SelectionChanged">
            <i:InvokeCommandAction Command="{Binding SelectedItemChangedCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</ListBox>