Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Switch should have "Clicked" event #8416

Closed
Aculeo opened this issue Nov 7, 2019 · 3 comments
Closed

[Enhancement] Switch should have "Clicked" event #8416

Aculeo opened this issue Nov 7, 2019 · 3 comments

Comments

@Aculeo
Copy link

Aculeo commented Nov 7, 2019

Summary

Currently Switch only has "Toggled" event, but that is also triggered by bindings or setting it programmatically. It would be nice if I can trigger a command when the user actually taps/clicks the switch.

API Changes

Add a "Clicked" event that is triggered when the user interacts with the Switch.

Intended Use Case

I have an example from an application I am currently working on:

<Switch IsToggled="{Binding IsJoined, Mode=TwoWay}">
    <Switch.Behaviors>
        <prism:EventToCommandBehavior EventName="Toggled"
                                        Command="{Binding BindingContext.MyCommand, Source={x:Reference MyElement}}"
                                        CommandParameter="{Binding}" />
    </Switch.Behaviors>

My expectation was that I can simply bind the switch to a model and react on the "Toggled" event to show a message when the user makes a change. But it's triggered just by the user scrolling through the list of switches because of the binding. Having a "Clicked" event would let me do just that.

Here is a SO thread about the same problem and a rather ugly workaround, so it doesn't look like I'm the only one who would like to see something similar: https://stackoverflow.com/questions/32975894/xamarin-forms-switch-sends-toggled-event-when-value-is-updated

@6Hat
Copy link

6Hat commented Jan 14, 2020

Highly agree... this is really annoying. How is everyone using the Switch? Every time my ListView refreshes the thing toggles!

@samhouts samhouts added this to Under consideration in Enhancements Feb 13, 2020
@dhindrik
Copy link
Contributor

I suggested adding Toggled and UnToggled Command properties. #6606

@jfversluis
Copy link
Member

Thanks for this suggestion! As Xamarin.Forms is now in maintenance mode, this will not happen anymore for Xamarin.Forms. We're only adding bugfixes and stability fixes.

If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap. If not, feel free to open a discussion to discuss a change first or open an issue with a detailed feature request. Thanks!

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
Enhancements automation moved this from Under consideration to Closed Feb 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Enhancements
  
Closed
Development

No branches or pull requests

4 participants