Search code examples
c#pixelsense

If statement targeting string


I'm new to C# and I am trying to develop an application for a Microsoft PixelSense using Surface 2.0 SDK and C#.

I'm loading my items into my dropdown menu using a string as followed:

_Menu1.ItemsSource = new string[] {
    "All",
    "Housing",
    "Transportation",
    "Food",
    "Personal Insurance",
    "Health",
    "Entertainment",
    "Personal care",
    "Cash",
    "Misc",
};

Now I want to call an if statement if for example "Housing" is selected. The if statement should then enable a button.

I tried the following:

if (_Menu1.ItemSource == 1){
    _Menu3.IsEnabled = true;   
};

This is obviously not working but it illustrates what I'm trying to accomplish.


Solution

  • Wouldn't that be:

    _Menu1.SelectedIndex == 1