I have a viewmodel which is a Conductor<object>.
The view associated with this viewmodel, has a datagrid. When a row in the datagrid is selected I show a detail for the selected item.
I set the activeitem (using ChangeActiveItem). Depending on the selectitem, I change the ActiveItem to one of six types of viewmodel:
the SelectedItem has a property which determines which viewmodel should be instantiated (and so which kind of view should be displayed as detail for the selectedItem)
But when the SelectedItem is changed on the datagrid, there is some validation to be done, determining if the ActiveItem can close. So the detail viewmodels implement CanClose
which determines if there are some unsaved changes or if all fields of the detail validate.
When there are some unsaved changes or the detail viewmodel does not validate, I want to prevent the datagrid from changing its selecteditem.
How can this be achieved? The SelectItem of the datagrid is bound to a property (CurrrentItem) on the viewmodel. I wanted to check in the setter of the CurrentItem if the ActiveItem can close,
but ActiveItem is of type object, so I can not call CanClose... Currently even when the detail viewmodel can not close, the selecteditem for the datagrid is changed anyway, so another detail view
is displayed, and any changes are lost.