I have a ‘Login’ button that I want to be disabled until 3 text boxes on the same WPF form are populated with text (user, password, server).
I have a backing object with a boolean property called IsLoginEnabled which returns True if and only if all 3 controls have data. However, when should I be checking this property? Should it be on the LostFocus event of each of the 3 dependent controls?
Thanks!
vg1890
I’d get the ‘backing object’ to raise the
IsLoginEnabledchanged event when any of the 3 fields are updated. You can then bind the button to the IsLoginEnabled property and not have to keep checking it.The pseudocode would look something like this:
The trick to this is naming the Event
[PropertyName]Changed(i.e.IsLogonEnabledChanged) – because raising this event will automagically notify any bound controls :o)