Reputation: 16361
I have a Caliburn Micro ViewModel inherited from Screen. The OnDeactivate should be "equivalent" to OnNavigateFrom in the View.
I want to prevent navigating back using the back button in some situation. Basically what I want to do is something like set Cancel=true in OnBackKeyPress but I want to do it in the View Model.
The OnDeactivate has a boolean close parameters, but when I set it to false there is no change.
Upvotes: 0
Views: 405
Reputation: 976
I think you can do this :
<Interactivity:Interaction.Triggers>
<Interactivity:EventTrigger
EventName="BackKeyPress">
<Command:EventToCommand
Command="{Binding BackKeyPressCommand}" />
</Interactivity:EventTrigger>
</Interactivity:Interaction.Triggers>
In caliburn micro i think it's :
cal:Message.Attach="[Event BackKeyPress]
But i don't know the code syntaxe sorry.
For take canceleventargs, don't forget to write PassEventArgsToCommand="True"
Upvotes: 1