Is there any way to close the view when user click on the close button (X) on the view or I just want to know something like ApplicationsCommand.close don't want to use IRequestCloseViewModel interface. thanks a lot
+1
A:
Yes, there is an ApplicationCommands.Close and it is used just like you suggest: Anywhere you have a close button, bind it to ApplicationCommands.Close like this:
<Button Content="{StaticResource CloseX}" Command="Close" />
Now in your base class you use for your views, register a event handler for this command and when it fires, remove the view from its parent or otherwise close the view. The details of how to do this depend on how you have your view windows managed. If each view is an independent window, just close the window. But if there is a view manager that manages layout, remove the view from it.
Ray Burns
2010-06-15 08:39:07