Problem with comboBox in WPF C#?

When you first select nothing happens, the next choice is behind by one pass, that is, if you choose "Auto", nothing happens, then select "3D Wallpapers" and get the "Cars" etc.


Xaml:
<combobox height="23" horizontalalignment="Left" margin="8,24,0,0" name="comboBox1" verticalalignment="Top" width="177" selectionchanged="comboBox1_SelectionChanged_1" background="#FFDDDDDD" istextsearchenabled="False">
 <comboboxitem isselected="True">Everything</comboboxitem>
<comboboxitem>Girls</comboboxitem>
<comboboxitem>Cars</comboboxitem>
 </combobox>


private void comboBox1_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
 if (comboBox1.Text == "Everything") { input = "all"; all_cat_id = ""; random_with_color(); }
 if (comboBox1.Text == "Cars") { input = "4"; all_cat_id = ""; random_with_color(); }
 if (comboBox1.Text == "3D Wallpaper") { input = "40"; all_cat_id = ""; random_with_color(); }
 if (comboBox1.Text == "Girl") { input = "42"; all_cat_id = ""; random_with_color(); }
 }


In what may be a problem for a couple of hours treading water...
October 8th 19 at 03:07
2 answers
October 8th 19 at 03:09
msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selectedindex(v=vs.85).aspx
msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selecteditem(v=vs.85).aspx
Seriously, Your issues will not solve, but damn, check result text not kosher to say the least.
well, Win Forms it works) - Wellington.Will commented on October 8th 19 at 03:12
Of course it will work, it will work everywhere, but especially for "recognition" which item is selected and there are indexes. - aniya.Kertzmann65 commented on October 8th 19 at 03:15
thank you - Wellington.Will commented on October 8th 19 at 03:18
October 8th 19 at 03:11
private void comboBox1_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
switch (comboBox1.SelectedIndex)
{
case 1: //Vehicles
//input = "all"; all_cat_id = ""; random_with_color();
break;
case 2: //3D Wallpapers
//input = "40"; all_cat_id = ""; random_with_color();
break;
case 3: //Girl
//input = "42"; all_cat_id = ""; random_with_color();
break;
default: //Everything
break;
}
}
0 begins =) - Wellington.Will commented on October 8th 19 at 03:14
All right, comments watch:) 0 is "Everything" - aniya.Kertzmann65 commented on October 8th 19 at 03:17
Sorry, didn't specify in the input variable default = "all"
About variables all_cat_id = ""; random_with_color(); they need to be taken out of logic, meaning to copy them everywhere. In General, I would suggest that you can do without them. - Wellington.Will commented on October 8th 19 at 03:20

Find more questions by tags ProgrammingWPFC