我有一个项目,需要一个至少具有2个ViewModel的窗口,一个用于基本逻辑,一个用于动态调整窗口大小。我不知道如何将窗口的DataContext设置为WindowViewModel
,该窗口当前从ShellViewModel
中提取所有信息。通常,在C#中,您可以在Window的代码中完成此操作:
this.DataContext = new WindowViewModel(this)
但是在VB中,Me.DataContext
甚至都不存在。
窗口视图模型
Imports Caliburn.Micro
Namespace MVVM
Public Class WindowViewModel
Inherits ShellViewModel
''This class handles all form resizing and window properties
Public Sub New(mWindow As Window)
Window = mWindow
End Sub
Private _window As Window 'Window we are manipulating
Public Property Window() As Window
Get
Return _window
End Get
Set(ByVal value As Window)
_window = value
End Set
End Property
End Class
End Namespace
ShellViewModel
Namespace MVVM
Public Class ShellViewModel
Inherits PropertyChangedBase
Sub New()
FormLoad()
End Sub
///Logic code here
End Class
End Namespace
如何将两个ViewModel都链接到窗口?