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

Make setting DataContext non destructive to view models #2260

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

cwensley
Copy link
Member

When setting a new DataContext to a control with an existing context, bindings could trigger events that would update other bindings before to either the new or old data context inadvertently. With these changes, any updated bindings will no longer modify the view model when they trigger other events.

  • Added IBindable.IsDataContextChanging which all controls inherit which can be used to perform specific logic during data context updates.
  • Added ObjectBinding.GetDataItem/TriggerDataValueChanged so it no longer has to store the data context object directly, causing all bindings to get the new data context immediately instead of one at a time
  • BindableBinding.BindDataContext() will no longer update the source values (view model) during a data context update.
  • Added a unit test to ensure desired behaviour of switching data contexts in this scenario.

When setting a new DataContext to a control with an existing context, bindings could trigger events that would update other bindings before to either the new or old data context inadvertently.  With these changes, any updated bindings will no longer modify the view model when they trigger other events.
- Added IBindable.IsDataContextChanging which all controls inherit which can be used to perform specific logic during data context updates.
- Added ObjectBinding.GetDataItem/TriggerDataValueChanged so it no longer has to store the data context object directly, causing all bindings to get the new data context immediately instead of one at a time
- BindableBinding.BindDataContext() will no longer update the source values (view model) during a data context update.
- Added a unit test to ensure desired behaviour of switching data contexts in this scenario.
@cwensley cwensley added this to the 2.7.1 milestone Jul 20, 2022
@cwensley cwensley merged commit 7a13d62 into picoe:develop Jul 20, 2022
@cwensley cwensley deleted the curtis/datacontext-binding-fixes branch July 20, 2022 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant