Jon
Jon

Reputation: 1727

Xamarin Picker add TagGesture

I'd like to add a tap gesture to the Picker - so when a value is selected (double tapped) I can call a method. I have tried the following. But it never fires! Any ideas?

  <Picker Grid.Row="5" Margin="0,0,100,0" Title=" -Select State" SelectedIndex="{Binding StatesSelectedIndex, Mode=TwoWay}" ItemsSource="{Binding PPStates}" ItemDisplayBinding="{Binding Path=[display_name]}">
                    <Picker.GestureRecognizers>
                      <TapGestureRecognizer
                              Command="{Binding OnTapPicker}"
                              NumberOfTapsRequired="1" />
                    </Picker.GestureRecognizers>
              </Picker>

I have tired the sample code in https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/gestures/tap/

By adding this Tapped="OnTapGestureRecognizerTapped"

Upvotes: 0

Views: 758

Answers (1)

Diceble
Diceble

Reputation: 807

I don't know how you could do that in the way you desire, but you could fire the selectedindexchanged. If I'm right this should fire when the user selected one of the 50 states. Here you have some documentation about the picker. https://developer.xamarin.com/api/type/Xamarin.Forms.Picker

If you want to use a picker that is bindable you should use this: https://forums.xamarin.com/discussion/30801/xamarin-forms-bindable-picker

let me know if this helped you.

Edit: Pickers are bindable by default nowadays

Upvotes: 1

Related Questions