看起来像Caliburn.Micro的WindowManager有WPF Windows的问题,它有构造函数参数,尽管该参数的类型在Caliburn.Micro IoC中注册。有没有更好的方法将所需的参数放入Window,除非在构造函数中使用臭味服务定位器IoC.Get(Of T)
?
Namespace Views
Class MainWindowView
Private _eventAggregator As IEventAggregator
Public Sub New(eventAggregator As IEventAggregator)
_eventAggregator = eventAggregator
End Sub
End Class
End Namespace
Sub ShowMainWindowView()
'Everything is correctly registered in Ioc...
Dim windowManager As New WindowManager
Dim viewModel As New MainWindowViewModel
windowManager.ShowDialog(viewModel)
'Exception is thrown about absence of parameterless constructor of MainWindowView
End Sub
答案 0 :(得分:0)
我尝试在新的,清晰的项目中再次重现此问题并且它可以工作 - 只需要在IoC容器中注册视图类型(Window),并且WindowManager会自动在视图的构造函数中注入所需的依赖项。 / p>