Search code examples
wpfmvvmmefcaliburn

View never becomes visible when implementing Caliburn + MEF on existing WPF App


I have an existing WPF project and I want to move it over to caliburn with MEF.

My shell is a viewmodel called MainViewModel this opens up a dialog using the DefaultWindowManager this is a login window this all works fine but after logging in the program stalls for a little bit then exits. and the MainView never becomes visible. With debugging I checked and verified that the MainView does get created it just never becomes active or visible.

I tried inheriting my MainViewModel from Screen, IShell and NotifyPropertyBase, IShell and IShell. Does anyone have any ideas or clues for me to try thanks.

I am not using caliburn in the MainView and ViewModel besides for the view to view model linking as I just took the old view/view models could this have to do with anything? Is there a way to turn of the ViewModelBinder for certain viewmodels/views?


Solution

  • Actually Rob Eisenberg of caliburn was very helpful and he helped me out with this issue.

    The problem was that when I switched to caliburn the LoginView was the first window to be opened and it was closed before the MainView window was opened.

    windows treats the first window opened as the mainwindow. and when the mainwindow is closed windows checks if other windows are open if not it closes the application.

    He provided a possible solution of making the loginviewmodel the shell and closing it after opening the mainviewmodel.