How to retrieve text value from selected item on Combobox

Hello, i need to read the text value of a selected item from a Combobox...
My code is :

<inputLayout:SfTextInputLayout 
                        Grid.Row="1"
                        Grid.Column="1"
                        Grid.ColumnSpan="4"
                        Hint="Nombre"
                        ContainerType="Outlined"
                        ContainerBackgroundColor="Black"
                        UnfocusedColor="Chartreuse"
                        OutlineCornerRadius="8"
                        InputViewPadding="8"
                        FocusedColor="Chartreuse">
                    <inputLayout:SfTextInputLayout.HintLabelStyle>
                        <inputLayout:LabelStyle FontSize="20" FontFamily="{StaticResource FuenteNormal}" >
                        </inputLayout:LabelStyle>
                    </inputLayout:SfTextInputLayout.HintLabelStyle>

                    <comboBox:SfComboBox 
                            DropDownItemHeight="30"
                            DropDownCornerRadius="10" 
                            DropDownTextSize="20" 
                            DropDownTextColor="Chartreuse" 
                            DropDownItemFontFamily="{StaticResource FuenteNormal}" 
                            DropDownBorderColor="Chartreuse" 
                            DropDownBackgroundColor="Black" 
                            HeightRequest="41" 
                            x:Name="txtEmpName" 
                            FontFamily="{StaticResource FuenteNormal}"
                            TextSize="20"
                            TextColor="Chartreuse" 
                            IsEditableMode="true" 
                            AllowFiltering="true" 
                            TextHighlightMode="FirstOccurrence" 
                            HighlightedTextColor="Red" 
                            HighlightedTextFontAttributes="Bold" 
                            SuggestionMode="StartsWith"
                            >
                        <comboBox:SfComboBox.ComboBoxSource>
                            <generic:List x:TypeArguments="x:String">
                                <x:String>Harina</x:String>
                                <x:String>Yogur</x:String>
                                <x:String>Pan</x:String>
                            </generic:List>
                        </comboBox:SfComboBox.ComboBoxSource>
                    </comboBox:SfComboBox>
                </inputLayout:SfTextInputLayout>


How can i do it?
Thanks in advance

3 Replies

RS Ramya Soundar Rajan Syncfusion Team May 22, 2020 09:38 AM UTC

Hi Luis, 
 
Greetings from Syncfusion. 
 
We would like to inform that you can get the SelectedItem value by using Selection Changed Event or Selected Item API. Please find the below code snippet and sample for this, 
 
Code Snippet: 
 
private void Button_Clicked(object sender, EventArgs e) 
        { 
            var Item = txtEmpName.SelectedItem; 
            DisplayAlert("Selected Item is", Item.ToString(), "Ok"); 
        } 
 
private void TxtEmpName_SelectionChanged(object sender, Syncfusion.XForms.ComboBox.SelectionChangedEventArgs e) 
        { 
            var SelectedItem = e.Value; 
            DisplayAlert("Selected Item is", SelectedItem.ToString(), "Ok"); 
        } 
 
 
Please refer the below link for more information. 
 
  
Please check with the above and let us know if you have any concerns. 
 
Regards, 
Ramya S 



LG Luis Gomez May 23, 2020 02:21 PM UTC

Thank you so much!
It works!



SP Sakthivel Palaniyappan Syncfusion Team May 25, 2020 01:28 AM UTC

Hi Luis,

Thanks for the update.

Please let us know if you need further assistance on this.

Regards,
Sakthivel P.
 


Loader.
Up arrow icon