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

Delayed Binding #7380

Open
furesoft opened this issue Jan 17, 2022 · 9 comments
Open

Delayed Binding #7380

furesoft opened this issue Jan 17, 2022 · 9 comments

Comments

@furesoft
Copy link

Is your feature request related to a problem? Please describe.
If wanting IO stuff on property change it would be better to trigger the propertychanged event after a delay

Describe the solution you'd like
A Delay Property on Binding MarkupExtension

@maxkatz6
Copy link
Member

maxkatz6 commented Jan 17, 2022

I understand this issue is more about feature parity with WPF, but that kind of delaying is easier to control in view model layer. Especially with flexible mvvm frameworks.

@Whiletru3
Copy link
Contributor

I also need the delay, especially in the slider

@RossenHristovEnscape
Copy link

We also need Binding.Delay a lot.

@timunie
Copy link
Contributor

timunie commented Mar 15, 2023

We also need Binding.Delay a lot.

what's the exact usecase here? Can't this be done (as a workaround for now) in the ViewModel using ReactiveUI's this.WhenAnyValue and .Throttle or using a DispatcherTimer?

@RossenHristovEnscape
Copy link

RossenHristovEnscape commented Mar 15, 2023

We also need Binding.Delay a lot.

what's the exact usecase here? Can't this be done (as a workaround for now) in the ViewModel using ReactiveUI's this.WhenAnyValue and .Throttle or using a DispatcherTimer?

Yes, this can definitely be done on the ViewModel level as I have done with a simple Debouncer using a Timer. But for every property that I need to be be debounced (i.e. delayed) I have to plague my view models with this same code. Having this functionality on the Binding level and being able to specify it in AXAML would lead to much cleaner code all around and the view models will not have to deal with this logic for every single property that they need to do so.

@timunie
Copy link
Contributor

timunie commented Mar 15, 2023

@rossen-hristov for sure in the future this can be considered, but for now we only have this "workaround". However, we need to make sure this doesn't have performance issues when implemented and it must be well tested, so nothing I see in the near future.

If you need to do it often, I can only suggest to write an attached property or a behavior which does what you need to do.

@jp2masa
Copy link
Contributor

jp2masa commented Mar 15, 2023

@rossen-hristov Just my opinion, but the more you can implement in the VM, the better. That way, if you eventually need to port to another framework, you don't have to duplicate any logic. In this example, you would have to duplicate the delay value between views, and if you need to update one, you need to look for all other instances to update as well.

@runelkrone
Copy link

I believe the initial use case for delay was in ListViews. When the user holds the arrow down the binding delay prevents sending change notifications for every element in the list. I generally avoid using the dispatcher in the VM whenever possible as it introduces a dependency on the UI that we generally try to avoid.

@npolyak
Copy link

npolyak commented Mar 27, 2024

Actually it is much easier to use the binding's Delay property rather than adding Throttle functionality to the View Model or adding a Throttle behavior to the UI level. So I think this feature is good to have.
An example where it is needed would be changing Text within the text box bound to a VM, triggering a search every time the text is changed. There should be some Throttle interval to prevent unnecessary searches.

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

No branches or pull requests

8 participants