Hello,
You can do this by adding itemsource in the background code.
For example, you have Picker in the layout and add button for testing.
<Button Text="click" Clicked="Button_Clicked" ></Button>
<Picker x:Name="MyPicker"></Picker>
Then you can set itemsource in the background code and add additional data to a Picker that already contains data.
I use ObservableCollection
to contains data, when you add data in it, it will update at the runtime.
public partial class MainPage : ContentPage
{
ObservableCollection<string> strings;
public MainPage()
{
InitializeComponent();
strings = new ObservableCollection<string>();
for (int i = 0; i < 10; i++)
{
strings.Add(i.ToString());
}
MyPicker.ItemsSource = strings;
}
private void Button_Clicked(object sender, EventArgs e)
{
strings.Add("1234");
}
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.