Olivia Olga Clarissa Olivia Olga Clarissa - 3 months ago 19
C# Question

Getting content value from combo box on C#

can we retrieve the content from combobox without data binding? This is my xaml code

<ComboBox x:Name="Choice" Header="Choice your eating time" PlaceholderText="Pilih" Width="200" SelectionChanged="Choice_SelectionChanged">
<ComboBoxItem Content="Breakfast" />
<ComboBoxItem Content="Lunch" />
<ComboBoxItem Content="Dinner"/>

I tried with
but the result will be Windows.UI.XAML.ComboBox, not the content of combobox. I want to pass it into listbox and when I used
it contain same result with SelectedItem.


@Olivia Olga Clarissa try this ..

Text = ((ComboBoxItem)Choice.SelectedItem).Content.ToString();


var comboBoxItem = Choice.Items[Choice.SelectedIndex] as ComboBoxItem;
if (comboBoxItem != null)
    string selectedcmb = comboBoxItem.Content.ToString();