Pergunta

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?

Foi útil?

Solução 2

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.

Outras dicas

I'll mention this in case your issue is the same as I had, as it slowed me down somewhat recently... If your Shell has some Imports that are not being satisfied then the Shell won't appear, and the effect is rather confusing. Ensure that you have [Import(AllowDefault=True)] as your Attribute or use [ImportMany]

However, since you do say that in debugging there is an instance, the issue might be in the way you are using Caliburn(Micro?). In this case, I suggest you copy a Caliburn example and then add your functionality - least then you'll know it once worked.

Rgds John

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top