Aaaaaaaa
Aaaaaaaa

Reputation: 2114

Where to call RaiseCanExecuteChanged?

I'm working with MVVM Light Toolkit, and I'd like to create a RelayCommand.

If my ViewModel has some String properties, which ones call the RaiseCanExecuteChanged in the setters, everything works fine, the command can be executed when I want.

But if I change the code, I create a Model class X, and it contains all of these properties, the ViewModel contains a property with type X, where should I call the RaiseCanExecuteChanged? In the Model class makes no sense, and the setter of the X in the ViewModel is not called.

Upvotes: 1

Views: 830

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564691

You will likely need to subscribe to the Model class PropertyChanged event, and raise your RaiseCanExecuteChanged when the model property changes.

Upvotes: 4

Related Questions