I have a login form that contains a username textbox and a password box.
I want the ok button to be enabled only when both the fields contain a value.
I have a converter that check for all the strings if they’re null or empty.
I placed a breakpoint on the first line of the Convert method, and it stops only when the MenuItem initializes, afterwords, i.e. when I change the text it doesn’t.
The following example works good, the problem is that the multibinding is not triggered when i change the text; it’s only bound when initializing the form:
<!--The following is placed in the OK button-->
<Button.IsEnabled>
<MultiBinding Converter="{StaticResource TrueForAllConverter}">
<Binding ElementName="tbUserName" Path="Text"/>
<Binding ElementName="tbPassword" Path="Password"/>
</MultiBinding>
</Button.IsEnabled>
I think the issue is that you don’t get notified when the remote binding source is changed (e.g. there is no an option to set UpdateTargetTrigger="PropertyChanged".
Any ideas?
I would suggest you look into command binding. A command can enable or disable your Login button automatically depending on some condition (ie. user name and password is not empty).
XAML command binding will look something like this
To register the command in XAML
Or in code behind
More readigin here.