Keep the viewmodel for ShowDialog

Topics: Questions
Aug 7, 2012 at 10:15 AM

Hello,

I wonder if it is possible to keep the viewmodel alive when using a DataWindow and the IUIVisualizerService.ShowDialog method (CloseViewModelOnUnloaded = false works only on UserControls).

I want to display a window (a search window with a result list) and process the result (a selected entry). Later on, I want to display the window again and the data should be still there (same search criterias, selected entry, etc.). So I guess I have to "keep" the viewmodel for the window.

Funny thing is, when re-opending the window, all the data is still displayed (well, the viewmodel that opens the window was never disposed), but the buttons do not work anymore (command bindings). I believe this is due to the fact, that the viewmodel has been closed.

Any ideas?

PS: Great Framework!

Coordinator
Aug 8, 2012 at 10:11 PM

No, this is not possible. You will have to recreate the view model the next time.

Aug 9, 2012 at 8:22 AM

Ok, I thought as much. But I am lucky, as my viewmodel just contains two other viewmodels that are bound to two usercontrol. They are not thrown away, so it's easy to recreate the main viewmodel.

Thanks anyaway