Closing a view from the viewmodel.

Apr 7, 2010 at 12:19 PM
Edited Apr 7, 2010 at 12:20 PM

I have implemented the ability for a View to be closed from a ViewModel.  It's just an event in the VM which is subscribed to by the V which triggers the view to close.   Would this be a feature which would be useful if it was in the Calcium core?  I would find it useful.

I've written it to prove a concept and not sure if my approach is the best way so am happy to discuss.

I created an IRequestViewClose and implement that on the VM.

If I wish the view to close I just call this.OnRequestViewClose(EventArgs.Empty);

The view then listens for the event and then calls 

var viewService = ServiceLocatorSingleton.Instance.GetInstance<IViewService>();
viewService.CloseView(this, true);


When using it with the ModalPopup I encounter the same ArgumentException problem at region.Deactivate(window.Content); as has already been reported.