Click here to Skip to main content
15,867,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to call method:
VB.NET
Private Sub OpenUserInput()
    Dim userInputDialogViewModel As New DlgViewModel()
    Dim result As Object = DlgService.Instance.ShowDialog(userInputDialogViewModel)

    If result.HasValue AndAlso result.Value Then
        Dim res As Object = userInputDialogViewModel.Mitarbeitername
    End If
End Sub

as RelayCommand.

ICommand works like this:
VB.NET
Public Property OpenUserInputCommand() As ICommand
        Dim cmdI As New Command(AddressOf OpenUserInput)
        OpenUserInputCommand = cmdI

But RelayCommand gives an error and does not compile.

What I have tried:

VB.NET
OpenUserInputCommand = New RelayCommand(Function(o)
                                            OpenUserInput()
                                        End Function, Function(o) True)

VB Editor shows this error:
BC36532: Nested function does not have a signature that is compatible with delegate '<delegatename>'
(delegatename = action)
Posted
Updated 24-Jan-22 3:13am
v3
Comments
M Imran Ansari 23-Jan-22 15:20pm    
Try the following line
Dim cmdI As New RelayCommand(AddressOf OpenUserInput)
Jo_vb.net 23-Jan-22 16:34pm    
That works fine, thank you.

1 solution

Inside your OpenUserInputCommand method, try the following command to get RelayCommand object:
VB.NET
Dim cmdI As New RelayCommand(AddressOf OpenUserInput)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900