I just need some Help translating from C# to VB.Net in this Case.
I try to learn about MVVM and WPF. I need to communicate between multiple Views. An easy way should be via MvvmLight Messaging. Unfortunately all Examples I could find are in C# and the Converter does not understand all of the Code.
What I have:
Register A Message
Messenger.Default.Register<GoToPageMessage>( this,( action ) => ReceiveMessage( action ) );
private object ReceiveMessage( GoToPageMessage action )
{
MsgBox( action.PageName );
return null;
}
Which the Converter can not translate.
Send a Message:
Private Function GoToPage2() As Object
Dim msg = New GoToPageMessage() With {
.PageName = "Page2"
}
Messenger.[Default].Send(Of GoToPageMessage)(msg)
Return Nothing
End Function`
The Message Class:
Public Class GoToPageMessage
Public Property PageName As String
End Class
Can Anyone please take a Look at this and maybe translate all to VB.Net?
I understand most of it, but not the action
Part. Never heard of this in VB.Net.
Thanks already for all the Help.
CodePudding user response:
The function in VB.NET:
Private Function ReceiveMessage(action As GoToPageMessage) As Object
MsgBox(action.PageName)
Return Nothing
End Function
And the registration:
Messenger.Default.Register(Of GoToPageMessage)(Me, Sub(x) ReceiveMessage(x))