开发者

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

开发者 https://www.devze.com 2023-02-08 23:25 出处:网络
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 wind

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 wor开发者_如何学Pythonks 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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消