Two fields in a picker - Xamarin Forms

0

Is it possible to have 2 fields in Picker ? Today I have a Category listing and would like to be able to put the Category Code up front.

TheXAMLcodeforPicker:

<Pickerx:Name="pckCategoria"
                        Title="Selecione uma Categoria"
                        ItemDisplayBinding="{Binding CATEGORIA}"
                        FontSize="Small"
                        Margin="10, 0, 10, 0">
                </Picker>

If it is not possible to bring the two contents in picker I can simply receive the Category Code when a Category is selected also, it would already be an exit, but so far I have not been able to do it, answer.

    
asked by anonymous 04.07.2018 / 23:00

2 answers

0

One option would be to create a property that merges the two contents, for example, the object would have three properties:
1-Code
2-Category
3-CategoryCode,
the latter would concatenate the previous two, and then could give Binding on the latter property.

Example:

XAML

<Picker x:Name="pckCategoria"
                        Title="Selecione uma Categoria"
                        ItemDisplayBinding="{Binding CategoriaCodigo}"
                        FontSize="Small"
                        Margin="10, 0, 10, 0">
                </Picker>

C #

Produto prod = new Produto();
prod.setCodigo(1);
prod.setCategoria("Alimento");
prod.setCategoriaCodigo(string.Format("{0} - {1}", prod.codigo, prod.categoria));
    
04.12.2018 / 13:46
-1

The Syncfusion platform has a multi-value Picker component, which I believe is exactly what you're looking for. There is a free Syncfusion license for individual developers and small businesses.

link

    
05.07.2018 / 16:14