Frage

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.

War es hilfreich?

Lösung

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"

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top