我有一个选择器,可以在其中更新用户/零售商的当前地址。所选值来自我要设置选择器所选项目的数据库。
我的XAML:
<local:CustomPicker x:Name="provincePicker" SelectedIndexChanged="provincePicker_SelectedIndexChanged" Unfocused="provincePicker_Unfocused" SelectedItem="{Binding DisplayText}" ItemsSource="{Binding ProvinceID}" ItemDisplayBinding="{Binding DisplayText}" StyleClass="fieldForm" IsEnabled="True">
<local:CustomPicker.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android" Value="HelveticaNeueLTPro-Lt.otf#HelveticaNeueLTPro-Lt"/>
</OnPlatform>
</local:CustomPicker.FontFamily>
XAML.CS
var getCode = conn.QueryAsync<RetailerGroupTable>("SELECT * FROM tblRetailerGroup WHERE RetailerCode=?", code);
var resultCount = getCode.Result.Count;
if (resultCount > 0)
{
var result = getCode.Result[0];
provincePicker.SelectedItem = result.ProvinceID;
}
答案 0 :(得分:1)
这些是配置Picker
ItemsSource
应该是IEnumerable<T>
,即List<MyClass>
或ObservableCollection<MyClass>
SelectedItem
-应该将其设置为ItemsSource
集合中包含的对象ItemDisplayBinding
-这是MyClass
属性的名称,将在Picker