You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WPF "CanExecute" has always worked because it is constantly polling the "CanExecute" to know if it can run. I know that this has change with MVVM Toolkit and any property that can affect a command must have "NotifyCanExeuteChangedFor" attribute to specifically identify commands to re-run logic for.
What I cannot figure out is, how can I architect my program with many classes (view models) where the observable property is not going to reside in the same class as the relay command.
// a property not in same class as XXXXCommand, fails. You cannot reference it
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(XXXXCommand))]
public string _firstName;
I've tried to reference with the class name that the Command resides in, but the project fails with: The target(s) of [NotifyCanExecuteChangedFor] must be an accessible IRelayCommand property, but "ChangePersonNameCommand" has no matches in type WpfApp1.ViewModel.PersonViewModel
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
WPF "CanExecute" has always worked because it is constantly polling the "CanExecute" to know if it can run. I know that this has change with MVVM Toolkit and any property that can affect a command must have "NotifyCanExeuteChangedFor" attribute to specifically identify commands to re-run logic for.
What I cannot figure out is, how can I architect my program with many classes (view models) where the observable property is not going to reside in the same class as the relay command.
// a property not in same class as XXXXCommand, fails. You cannot reference it
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(XXXXCommand))]
public string _firstName;
I've tried to reference with the class name that the Command resides in, but the project fails with: The target(s) of [NotifyCanExecuteChangedFor] must be an accessible IRelayCommand property, but "ChangePersonNameCommand" has no matches in type WpfApp1.ViewModel.PersonViewModel
Thanks
Beta Was this translation helpful? Give feedback.
All reactions