How to trigger a picker from a GridView column click?

I have a picker on a Grid view. I want to trigger the SelectedItem event on grid view column click in MVVM pattern. I have added GestureRecognizers, but not sure how to trigger the picker from ViewModel.

                                <RowDefinition Height="80"/>
                                <RowDefinition Height="25"/>
                                <RowDefinition Height="11"/>

                                <TapGestureRecognizer Command="{Binding TriggerMinutePicker}" NumberOfTapsRequired="1"/>

                            <Image Source="{Binding ImageOne" HeightRequest="70" VerticalOptions="End" />

                            <picker:BorderlessPicker Grid.Row="1"
                                         ItemsSource="{Binding PickerMinutes}"
                                         ItemDisplayBinding="{Binding Value}"
                                         SelectedItem="{Binding SelectedMinute}"
                                         SelectedIndex="{Binding SelectedMinuteIndex}"
                                         Style="{StaticResource pickerMinuteStyle}">

                            <Label Grid.Row="2" Style="{StaticResource labelMinute}" Text="MINUTES" />


Best Answers


  • ColeXColeX Member, Xamarin Team Xamurai
    edited September 2018

    You have create binding for SelectedItem , does the picker show the selected one as the value in viewmodel ?

    What do you mean by trigger the SelectedItem event ?

  • benazir0benazir0 Member ✭✭

    @ColeX I get the whole selected item.
    Sorry for the confusion. I just want to trigger the picker so that it pops up on the screen whenever I tap on a grid-view column; in this case I have only one column. Please ignore the triggering selected item part.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited September 2018


    picker.Focus(); // the Picker name set in xaml

    inside the action of Command.

  • benazir0benazir0 Member ✭✭

    Sorry, could you be more specific? How do I pass the picker reference on the TriggerMinutePicker command on TapGestureRecognizer above. Do you mean passing it as a parameter?

  • benazir0benazir0 Member ✭✭

    Thanks both of you.

Sign In or Register to comment.