实现 Caliburn + 时,视图永远不会变得可见。现有 WPF 应用程序上的 MEF
我有一个现有的 WPF 项目,我想使用 MEF 将其移至 caliburn。
我的 shell 是一个名为 MainViewModel 的视图模型,它使用 DefaultWindowManager 打开一个对话框,这是一个登录窗口,一切正常,但登录后程序会停顿一会儿然后退出。并且 MainView 永远不会变得可见。通过调试,我检查并验证了 MainView 确实已创建,但它永远不会变得活动或可见。
我尝试从 Screen、IShell 和 NotifyPropertyBase、IShell 和 IShell 继承我的 MainViewModel。有谁有任何想法或线索供我尝试,谢谢。
除了视图到视图模型链接之外,我没有在 MainView 和 ViewModel 中使用 caliburn,因为我只是采用了旧的视图/视图模型,这可能与任何事情有关吗?有没有办法为某些视图模型/视图关闭 ViewModelBinder?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你的问题和我一样,我会提到这一点,因为它最近让我放慢了速度......如果你的 Shell 有一些不满足的导入,那么 Shell 将不会出现,效果相当好令人困惑。
确保您将 [Import(AllowDefault=True)] 作为您的属性或使用 [ImportMany]
但是,由于您确实说在调试中有一个实例,所以问题可能出在您使用 Caliburn(Micro?) 的方式上。在这种情况下,我建议您复制一个 Caliburn 示例,然后添加您的功能 - 至少这样您就会知道它曾经有效。
参考值
约翰
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
事实上,Caliburn 的 Rob Eisenberg 非常乐于助人,他帮我解决了这个问题。
问题是,当我切换到 calibburn 时,LoginView 是第一个打开的窗口,并且它在 MainView 窗口打开之前关闭。
windows 将第一个打开的窗口视为主窗口。当主窗口关闭时,窗口检查其他窗口是否打开,如果没有打开,则关闭应用程序。
他提供了一种可能的解决方案,将loginviewmodel作为shell并在打开mainviewmodel后将其关闭。
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.