Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if-else combobox

Tags:

c#

combobox

uwp

I tried this code to test out the if-else combobox.

private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if(comboBox.SelectedItem.ToString() == "90")
            {
                btnStart.IsEnabled = true;
            }
        }

Combobox setup

<ComboBox x:Name="comboBox" Width="230" PlaceholderText="Select the following degree" SelectionChanged="comboBox_SelectionChanged">
                <ComboBoxItem>
                    90
                </ComboBoxItem>
                <ComboBoxItem>
                    45
                </ComboBoxItem>
            </ComboBox>

I have disable my "start button" at the beginning. So when I select 90 in my combox, the "start button" should be enabled right ? But it doesn't enables when I select 90, the "start button" is still disabled. What is the error here ?

like image 971
Hidden Avatar asked Mar 31 '26 01:03

Hidden


1 Answers

You can debug/step into your program using F11. Hitting F11 once will "step into" your program. You can then continue to hit F11 which will run through your program and highlight the code that it is executing line-by-line. Once it stops, click on your "90" combo box item and continue to hit F11 until it reaches the line:

if(comboBox.SelectedItem.ToString() == "90")

At that point, hover your mouse over "SelectedItem" and it should show you the data that is stored in that property.

I hope this helps!

like image 88
santucklaws Avatar answered Apr 02 '26 14:04

santucklaws



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!