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

Updated the NumberBox ValueProperty's default BindingMode to be TwoWay #754

Merged

Conversation

syntax-tm
Copy link
Contributor

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

Currently, a Binding to the NumberBox.Value is OneWay by default. The Source (DataContext) raising an INotifyPropertyChanged event will trigger a change in the NumberBox. However, a change in the NumberBox will not update the Source.

If you are binding to the NumberBox.Value (using the default BindingMode, OneWay):

  • The increment, decrement, and clear operations are not updating the Source
    • This is made worse by the fact the Text displayed will not match the actual Value
    • The Value property of the NumberBox changing means that will no longer match the Source property
  • Manually inputting (typing) a number does not update the Source property

I created a test project to demonstrate this, but here's some screenshots that show the issue that currently exists (OneWay) and then the solution (TwoWay).

WpfDemoApp.zip

What is the new behavior?

  • NumberBox.Value default BindingMode is now TwoWay and functions as expected

Other information

I was surprised that this wasn't already set for this control and I'm not sure if there's any reasoning for why that is but here's an excerpt from the MSDN docs on BindingMode regarding the default bindings of "user-editable control properties":

The default is Default, which returns the default binding mode value of the target dependency property. However, the default value varies for each dependency property. In general, user-editable control properties, such as those of text boxes and check boxes, default to two-way bindings, whereas most other properties default to one-way bindings. (source)

@cla-bot
Copy link

cla-bot bot commented Sep 9, 2023

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @syntax-tm on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added.

@syntax-tm
Copy link
Contributor Author

I'm not sure what method of contact you guys prefer for the signing the Contributor License Agreement, but if it's possible you can consider this my acceptance of the agreement. If there's anything more you need from me just let me know. Thanks!

@syntax-tm
Copy link
Contributor Author

Do you want me to revert the last merge and rebase off of the latest?

@pomianowski pomianowski merged commit 15de62d into lepoco:development Sep 12, 2023
1 of 3 checks passed
@syntax-tm syntax-tm deleted the feature/add-numberbox-binding-mode branch September 17, 2023 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants