您可以通過將CLR屬性與int類型綁定到Picker.SelectedIndex屬性(對於這兩個Picker)來實現您的要求,如下面的代碼示例中所示。
C#:
型號:
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>
請參考更多詳細信息,下面的示例: 樣本鏈接:http://www.syncfusion.com/downloads/support/directtrac/169982/ze/XamarinForms1797267025
問候,
Ashok