Вопрос

I'm trying to use Relay command from MVVMLight and I'm struggling to find the right syntax to pass the parameter to both the Execute method and also the CanExecute method.

Below is my failed attempt

NewMessageCommand = new RelayCommand<object>(
    (obj) => NewChatMessage(obj.panelID),
    (obj) => (obj.AccessLevelCode.Equals(Constants.PANEL_ACCESS_LEVEL_FULLACCESS)));

Any help or direction would be most appreciated

Это было полезно?

Решение

You need to specify the actual type of the parameter if you need to access its members. For instance:

NewMessageCommand = new RelayCommand<MyClass>(
            (obj) => NewChatMessage(obj.panelID),
            (obj) => (obj.AccessLevelCode.Equals(Constants.PANEL_ACCESS_LEVEL_FULLACCESS))                
            );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top