I'm trying to use C# to select an item in a listbox using a switch statement but nothing happens:
This is my current code:
XAML
<ListBox x:Name="test" (XAML OMITED) SelectionChanged="test_SelectionChanged">
<ListBoxItem Content="name 1" />
c#
private void test_SelectionChanged(object sender, System.EventArgs e)
{
switch (test.SelectedItem.ToString())
{
case "name 1":
MessageBox.Show("X");
break;
case "name 2":
MessageBox.Show("X");
break;
default:
break;
}
thanks