how to change selected index of one picker in other pickers selectedindexchanged event in syncfusion

699 Views Asked by At

I am using syncfusion datagrid in my xamarin.forms application. I used 2 picker in 2 columns of sfdatagrid.

how can I set selectedindex = 0 of 2nd picker on selectedindexchanged event of 1st picker.as Icoudnt find its refence in my event.pls help.

1

There are 1 best solutions below

0
On BEST ANSWER

You can achieve your requirement by binding CLR property with int type to Picker.SelectedIndex property for both Picker, like in the below code example.

C#:

Model:

private int selectedindex;
public int Selectedindex
{
 get
 {
     return selectedindex;
 }
 set
 {
     selectedindex = value;
     RaisePropertyChanged("Selectedindex");
 }
}

XAML

<sfgrid:GridTemplateColumn MappingName="Picker1" >
 <sfgrid:GridTemplateColumn.CellTemplate>
  <DataTemplate>
   <Picker TextColor="Black" 
          SelectedIndex="{Binding Selectedindex, Mode=TwoWay}" >
    <Picker.Items>
      <x:String>1</x:String>
      <x:String>2</x:String>
    </Picker.Items>
   </Picker>
  </DataTemplate>
 </sfgrid:GridTemplateColumn.CellTemplate>
</sfgrid:GridTemplateColumn>

<sfgrid:GridTemplateColumn MappingName="Picker2" >
 <sfgrid:GridTemplateColumn.CellTemplate>
  <DataTemplate>
   <Picker TextColor="Black" 
    SelectedIndex="{Binding Selectedindex, Mode=TwoWay}" >
    <Picker.Items>
      <x:String>3</x:String>
      <x:String>4</x:String>
    </Picker.Items>
   </Picker>
  </DataTemplate>
 </sfgrid:GridTemplateColumn.CellTemplate>
</sfgrid:GridTemplateColumn>

Please refer the below sample for more details: Sample link: http://www.syncfusion.com/downloads/support/directtrac/169982/ze/XamarinForms1797267025

Regards,

Ashok