-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Binding updates for buttons from TextBoxHelper.ButtonCommand #3924
Comments
Hi @Rerago I think your problem is this line:
You may try to copy the entire Also please have a look into the Demo App. There is an example for MahApps.Metro/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/TextExamples.xaml Lines 150 to 155 in 698e4d6
Happy coding |
Hi @timunie I think that:
is totally ok at this point. But I think that we need an ".UpdateSource();" before executing the command. This should not break and should lead to an expected result. Rerago |
@Rerago in the end @punker76 has to decide, but if you have a working solution (sounds like this) feel free to raise a pull request. Any contribution is welcome 😊 Happy coding |
If @punker76 finds my idea in okay I like to do a PR. But it would be nice if he says something about it. Not that I make the work unnecessary :). But I just did it now (hope its fine^^): Unfortunately I do not know which one would be the corresponding property in the rich text box. But the others are built in correctly. |
So I have reworked my pull request again. I checked the other property and this one has the DefaultUpdateSourceTrigger not on LostFocus. And therefore no change is necessary here. So the change is very small now. |
Describe the feature
I would like the bindings to be updated when clicking on the buttons created by "TextBoxHelper.ButtonCommand".
Additional context
Good afternoon,
i have a question about the behaviour of ButtonCommand in a textbox and the update of bindings.
Let us assume you have a textbox and a button. If the user enters something into the textbox and then clicks on the button to perform the action the button will have access to the value of the text property (which is assigned by the binding of the ViewModel). Since TextBox.Text has the default binding update to "LostFocus".
If you want to replace the following constellation with "TextBoxHelper.ButtonCommand" there is a problem. Clicking on the button does not create a LostFocus (which I had expected or hoped for) and the binding is not updated. This has the consequence that you can't access the property in the command.
Of course you could work around this as follows:
Couldn't we maybe add "UpdateSource" here:
https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs#L895
Because I think that would reflect the expected behavior again? Or am I wrong?
Some example code
If you enter text into the TextBox and then click on the created button the MessageBox is empty. If you click on the dummy button before (through the LostFocus) the MessageBox shows the content of the TextBox.
The text was updated successfully, but these errors were encountered: