Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]DelegateCommand.ObservesProperty method does not function correctly #3158

Closed
ColoCoffee opened this issue Jun 8, 2024 · 1 comment
Closed

Comments

@ColoCoffee
Copy link

ColoCoffee commented Jun 8, 2024

Description

I have a WPF project, and I want to monitor a property through the ObservesProperty method of a DelegateCommand, and trigger DelegateCommandBase.RaiseCanExecuteChanged by a change in the property. Unfortunately, no matter what I try, it doesn't work.

Here is a link to the repo - https://github.com/ColoCoffee/PrismTest.git

Steps to Reproduce

  1. Create project, add Prism.
  2. create 2 windows and 2 Viewmodels, Binding command;
  3. Viewmodel inherits BindableBase.
  4. Create the corresponding DelegateCommand in the ViewModel, specify its executeMethod and canExecuteMethod during initialization, and ObservesProperty() to monitor the properties.
  5. is monitored by the value of the property changes to trigger RaisePropertyChanged();.
  6. the canExecuteMethod is not re-executed.

Prism

Platform with bug

WPF

Affected platforms

Windows

Did you find any workaround?

no

Relevant log output

No response

@brianlagunas
Copy link
Member

You have some big problems in your code, but that's not what's causing this specific issue. ObservesProperty only works with public properties. This means it will not work with a private variable.

This is your issue -> private StartViewModel _startViewModel;

Change that to a public property and it will work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants