Can you please Window.Closed me how to hang the command ( ICommand ) from the ViewModel on the Window.Closed event? For the sake of observing the principles of MVVM, I don’t want to use a regular handler.

  • The principles of MVVM are only shared by who does what. They do not prohibit the use of the code-behind view for the needs of the form. - vitidev
  • You should not want this. In MVVM, the view model should control visibility. Recheck your design. - VladD

1 answer 1

Use EventTrigger in combination with InvokeCommandAction from Windows. Interactivity namespace:

 <Window ...> <i:Interaction.Triggers> <i:EventTrigger EventName="Closed"> <i:InvokeCommandAction Command="{Binding WindowClosedCommand}"/> </i:EventTrigger> </i:Interaction.Triggers> </Window>