Q:

Running different method when a different selection is made in a comboBox

I am trying to create a combo box with different options within it and fire different methods for when an option has been selected. However when I run the app and select an option nothing happens. Here is a snippet of the code:
<ComboBox x:Name="comboBox" HorizontalAlignment="Left" Margin="10,84,0,0" VerticalAlignment="Top" Width="100" SelectionChanged="comboBox_SelectionChanged" SelectedItem="{Binding Path=index, Mode=TwoWay}" SelectedValuePath="Tag">
    <ComboBoxItem Content="Kilograms" Tag="0"></ComboBoxItem>
    <ComboBoxItem Content="Pounds" Tag="1"></ComboBoxItem>
</ComboBox>

private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    ComboBox Selector = (sender as ComboBox);
    int index = Selector.SelectedIndex;

    switch(Selector.ToString())
    {
        case "0":
            workOutKilo();
            break;
        case "1":
            break;
    }
}

private void workOutPounds()
{
    MessageBox.Show("This is the pounds conversion");
}

private void workOutKilo()
{
    MessageBox.Show("This is the kilo conversion");
}

How can I get this working so that the methods will run when an option within the combo box is selected and display the message to the screen?

A:

Don't use the sender object as switch condition. Instead use the fetched index:
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    var comboBox = sender as ComboBox;
    int index = comboBox.SelectedIndex;

    switch (index)
    {
        case 0:
            workOutKilo();
            break;
        case 1:
            workOutPounds();
            break;
    }
}

Your current code does not work, because calling the ToString method on the ComboBox object yields the following text: System.Windows.Controls.ComboBox Items.Count:2, which is neither the string "0", nor the string "1".

