【问题标题】:Xamarin Picker add TagGestureXamarin 选择器添加 TagGesture
【发布时间】:2017-05-29 21:56:23
【问题描述】:

我想在 Picker 中添加一个点击手势——所以当一个值被选择(双击)时,我可以调用一个方法。我尝试了以下方法。但它永远不会着火!有什么想法吗?

  <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>

我已经厌倦了示例代码 https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/gestures/tap/

通过添加此Tapped="OnTapGestureRecognizerTapped"

【问题讨论】:

  • 你的选择器有一些物品?
  • 是的.. 50 个州

标签: xamarin


【解决方案1】:

我不知道您如何以您希望的方式做到这一点,但您可以触发 selectedindexchanged。如果我是对的,这应该在用户选择 50 个州之一时触发。 Here你有一些关于选择器的文档。 https://developer.xamarin.com/api/type/Xamarin.Forms.Picker

如果你想使用一个可绑定的选择器,你应该使用这个: https://forums.xamarin.com/discussion/30801/xamarin-forms-bindable-picker

如果这对你有帮助,请告诉我。

编辑: 现在默认选择器是可绑定的

【讨论】:

    猜你喜欢
    • 2019-02-05
    • 1970-01-01
    • 2020-01-15
    • 1970-01-01
    • 2020-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    相关资源
    最近更新 更多