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

Added Binding.Delay feature #16805

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TomEdwardsEnscape
Copy link
Contributor

Updates to binding sources can now be delayed by configuring each binding.

What is the updated/expected behavior with this PR?

The delay feature works in the same way as WPF's. When the target property is changed, a DispatcherTimer is started (or restarted) and the source is only updated when the timer elapses.

As with WPF, there is no delay when the source is updated via UpdateSourceTrigger.LostFocus or BindingExpressionBase.UpdateSource(). Nor is there a delay when BindingMode.OneWayToSource is active and a new source object is provided.

Other binding types

MultiBinding does not support writing back to the source, so does not have a Delay property.

TemplateBinding could support Delay but I didn't implement it there. WPF's equivalent type doesn't have it, and I also don't see a use case within the context of a ControlTemplate.

Breaking changes

None

Obsoletions / Deprecations

None

Fixed issues

Fixes #7380

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051473-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051481-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

{
// The value must be read from the target object instead of using the value from the event
// because the value may have changed again between the time the event was raised and now.
WriteTargetValueToSource();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to resolve a conflict here. In #17073 @grokys changed the line to:

WriteValueToSource(target.GetValue(TargetProperty));

But this skips the value equality check in WriteTargetValueToSource, which is used everywhere else. It looks a lot like this was an oversight, but perhaps there was a reason?

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0052802-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delayed Binding
3 participants