1
votes

in my Windows Phone application I have following scenario:

  1. I have two ListBox'es f.e lbx1 and lbx2
  2. ViewModel loads data to lbx1
  3. User tap on ListBox, command is fired, ViewModel set visibility of lbx1 to collapsed and lbx2 to visilbe.

Now I want to do following thing: when lbx2 is visible I want to intercept OnBackKeyPress event in My ViewModel so that I can change visibility of lbx1 to visible and lbx2 to collapsed.

Is it even possible with mvvm.light ?

1

1 Answers

2
votes

Ok, found my aswer: In page.xaml insert:

<i:Interaction.Triggers>
    <i:EventTrigger
        EventName="BackKeyPress">
        <GalaSoft_MvvmLight_Command:EventToCommand
            Command="{Binding BackKeyPressCommand}"
            PassEventArgsToCommand="True"
            />
    </i:EventTrigger>
</i:Interaction.Triggers>

Where Command is my ViewModel command, and PassEventArgsToCommand="True" enables me to cancel event when event is fired