This project is read-only.

Window Closing Confirmation

Mar 21, 2011 at 11:33 AM

Hi all,


I have OnClosing override on my VM. When I navigate to another view my code is executed correctly, but when I close my WPF application my code is not run ...


Any idea about this ? How I can intercept form closing event correctly ?




Hervé (CrazyHT)


Apr 11, 2011 at 12:38 PM

Hi Herve, sorry for the delay in replying.. one simple/direct way to handle the closing event would be to do something like:

	<i:EventTrigger EventName="Closing">
		<n:ExecuteCommandAction Command="{Binding SaveBlockCommand}"  />

Also, a related way to get a command executed when the View is unloaded is to specify it with the BridgeViewModel behavior:

	<n:BridgeViewModelBehavior UnloadedCommand="{Binding SaveCommand}"/>	

Hope this helps,

Apr 15, 2011 at 8:01 AM

Hi Rishi,


In fact this solution work, but I want have same comportment of Closing with Navigation for all my View.

And your solution isn't generic.