Link to home
Start Free TrialLog in
Avatar of a_anis3000
a_anis3000Flag for Egypt

asked on

Displaying selected item of a wpf ComboBox in a messagebox

I have the following ComboBox in XAML Code

<ComboBox Name="angleComboBox" SelectionChanged="angleComboBox_SelectionChanged">
                    <ComboBoxItem>Degree</ComboBoxItem>
                    <ComboBoxItem>Radian</ComboBoxItem>
</ComboBox>

along with its following event handler below

private void angleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selection = angleComboBox.SelectionBoxItem as string;
            MessageBox.Show(selection);
        }

What I am trying to do is get the messagebox to display whatever I am selecting in the combobox for example a messagebox display the word Degree when Degree is selected from the ComboBox. For some reason selecting Degree in the ComboBox yields and empty message box and selecting Radian yields a messagebox with the word Degree instead of Radians.

ASKER CERTIFIED SOLUTION
Avatar of mikebirt
mikebirt
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of _Katka_
_Katka_
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial