Hi Stjepan,
Regarding Query: How can I get the selected value from the sfpicker and
display it in a label?
As per the shared information, we suspect your requirement is “Getting
the selected item value from the picker in the .NET MAUI Picker and show it in
label”. By using the SelectionChanged event of the picker you can achieve
this requirement in sample level. We have attached the code snippet for the
same.
Code snippet:
|
<StackLayout>
<Label x:Name="label" Text="Picker"
VerticalOptions="Center" HorizontalOptions="Center" BackgroundColor="Coral"/>
<picker:SfPicker x:Name="picker"
Mode="Dialog" IsOpen="True" SelectionChanged="picker_SelectionChanged">
<picker:SfPicker.FooterView>
<picker:PickerFooterView Height="40"/>
</picker:SfPicker.FooterView>
</picker:SfPicker>
</StackLayout>
private void picker_SelectionChanged(object sender, PickerSelectionChangedEventArgs e)
{
ObservableCollection<string> dataSource = new ObservableCollection<string>();
if (this.picker.Columns != null && this.picker.Columns[0].ItemsSource
is ICollection collection)
{
if (collection.OfType<string>().Any())
{
foreach (string item in collection)
{
dataSource.Add(item);
}
}
}
label.Text = dataSource[this.picker.Columns![0].SelectedIndex];
}
|
Screenshot:

We hope that this helps you. Please let us know if you need
further assistance.
Regards,
Indumathi R