-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
Button not enabling when its CanX property returns true #148
Comments
I realize I am missing property changed notifications. Through all of the examples I saw I assumed this was handled implicitly by Stylet for me. After changing my property setters to the following, it works as expected. public string Username
{
get => _username;
set
{
SetAndNotify(ref _username, value);
NotifyOfPropertyChange(() => CanLogin);
}
} If there's a more intended way to handle this please let me know - I'll close this in a bit. |
Yes, you'll need to raise an INPC event for I normally wire things together in the constructor: Bind(s => s.Username, (o, e) => NotifyOfPropertyChange(nameof(CanLogin))); |
Re-opening as a reminder to improve the docs |
I'd be happy to handle the wiki change if you'd like |
Sure, please go ahead! |
Updated https://github.com/canton7/Stylet/wiki/PropertyChangedBase examples to include the "wire in constructor" version and replaced the update-in-method examples with update-in-property examples to make it more clear. If you're happy with the changes, please close this issue. |
Hi, I have a question regarding Guard Properties. Wasn't sure where to ask but this thread seems kind of related. How can I pass the CommandParameter into a guard property? So a button would be enabled/disabled depending on the state of the bound model. |
@haven1433 Thank you! @ShemJM That's a limitation of guard properties, and a reason why guard methods are suggested in #147 (although it's not straightforward). It's probably easiest to bind that thing to another property in the VM, and inspect it from your guard property's getter. Make sure you raise the appropriate INPC events. |
@canton7 Thanks. I'll give it a go and thanks for Stylet! |
The wiki page on guards now uses INPC throughout |
Reproduced in this repo here: https://github.com/mariocatch/stylet-foo
I'm using the default Stylet template with dotnet core 3.1.
I simply added a property/method for reproducing the issue.
Breakpoint on
CanDo
property is hit once and never hit again. Changing the value in theTextBox
, while callingset
, does not retrigger theCanDo
property.I've also tried using backing fields with
SetAndNotify
, to no avail:The text was updated successfully, but these errors were encountered: