Hi, everybody.
From the database I get a list of objects ({Id, Caption}) that I want to display in the Picker.
Only text values are added, and getting the selected item goes by index, and I need to work with Id.
I read that you can add a collection to ItemsSource, but in my case, a collection of objects is used.
Database.cs:
public class MyType
{
[PrimaryKey, AutoIncrement, NotNull]
public int Id { get; set; }
[MaxLength(50), Unique, NotNull]
public string Caption { get; set; }
}
public Task<List<MyType>> MyTypeGetAsync()
{
return _database.Table<MyType>().ToListAsync();
}
Page1.cs:
private List<MyType> aMyType;
public async void MyTypeReload()
{
...
aMyType = await App.Database.MyTypeGetAsync();
...
my_list_item.ItemsSource = aMyType;
}
Is it possible to substitute values in the Picker in such a way as to output the Caption value, and get the Id value for the selected element?