In android this is simple and straightforward. In WP7 it’s not (at least for me).
What I’m trying to achieve:
I want to have a ListPicker:
<toolkit:ListPicker>
I want to poupulate it with Strings (same way you do with xml arrays for spinners in android)
I want the string to be displayed to the user as an item inside the picker.
It would also be good if the solution to this supported internatiolization.
I tried creating Resources with a list of strings but couldn’t figure out how to “bind” it to the control.
I don’t want the string values to be hardcoded in .cs files.
The ‘standard’ way to populate a
ListPickercontrol is to set itsItemsSourceproperty to the collection which you wish to render. TheListPickerhas anItemTemplatewhich details how each item is rendered. If you do not specify anItemTemplate, the default template will be used antoString()invoked on each of the items in your collection in order to render them.See this tutorial for more details:
ListPicker for WP7 in depth
So a simple example would be:
And in code-behind: