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

Implement ValueChanged for slider #10080

Closed
squidink7 opened this issue Jan 25, 2023 · 7 comments · Fixed by #11362
Closed

Implement ValueChanged for slider #10080

squidink7 opened this issue Jan 25, 2023 · 7 comments · Fixed by #11362
Labels
enhancement help-wanted A contribution from the community would be most welcome.

Comments

@squidink7
Copy link

Is your feature request related to a problem? Please describe.
Currently there is no (easy) way to react to a sliders value changing. I attempted to subscribe to the slider's thumb's DragCompleted event, but due to #4210 even that doesn't work.

Describe the solution you'd like
A ValueChanged event that gets triggered when a slider moves, similar to NumericUpDown's ValueChanged event (or WPF's slider)

Describe alternatives you've considered
Fixing #4210 would also allow this behavior, although is a bit more cumbersome.

@maxkatz6
Copy link
Member

Currently there is no (easy) way to react to a sliders value changing.

You just subscribe on PropertyChanged and check for value property.

But this event does make sense anyway for consistency with our couple of new events added recently, i.e. TextChanged.

@robloo
Copy link
Contributor

robloo commented Jan 26, 2023

I definitely like adding support for the older Event pattern. It helps a lot with migrating code. Events also CAN in several instances give more information than a property changed notification.

@jonchardy
Copy link

Is this the correct way of doing this until implemented?

slider.GetPropertyChangedObservable(Slider.ValueProperty).AddClassHandler<Slider>((t, args) => {
  ...
});

@timunie
Copy link
Contributor

timunie commented Apr 3, 2023

In Avalonia, you can just listen to PropertyChanged which is very handy. But the way you have written will also work. So test both and decide what suits your situation best.

@Antix-Development
Copy link

As a new user to Avalonia I found it very confusing that there was no ValueChanged event for sliders when they exist for other controls.
Although you can "just subscribe on PropertyChanged and check for value property", it would be much better from a new users perspective to have ValueChanged events, especially when new users are generally coming from an environment where such things exist.

@maxkatz6 maxkatz6 added the help-wanted A contribution from the community would be most welcome. label May 3, 2023
@robloo
Copy link
Contributor

robloo commented May 13, 2023

@squidink7 I opened #11362 to close this. Please take a look if you can.

@squidink7
Copy link
Author

Looks good to me! Everything seems well with that PR, and in the case something goes wrong this can be reopened if need be, but otherwise this issue can be closed! Thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help-wanted A contribution from the community would be most welcome.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants