Hi all,
I have some simple example WinForms code which I am trying to translate into WPF. The idea is to change the items within a ComboBox if a certain item is picked and drop down the ComboBox again if this happened. The WinForms code is:
if (list.Text.Equals("C>>"))
{
comboBox1.Items.Clear();
comboBox1.Items.Add("<<");
comboBox1.Items.Add("C1");
comboBox1.Items.Add("C2");
comboBox1.Items.Add("C3");
comboBox1.Items.Add("C4");
comboBox1.Items.Add("C5");
comboBox1.Items.Add("C6");
comboBox1.DroppedDown = true;
}
Although I though that this would be quite a simple change, using
private void hotListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (hotListBox.SelectedItem != null)
{
if (hotListBox.SelectedItem.Equals("b >>"))
{
hotListBox.ItemsSource = secondList;
hotListBox.IsDropDownOpen = true;
}
else if (hotListBox.SelectedItem.Equals("<<"))
{
hotListBox.ItemsSource = initialList;
hotListBox.IsDropDownOpen = true;
}
else if (hotListBox.SelectedItem.Equals("d >>"))
{
hotListBox.ItemsSource = thirdList;
hotListBox.IsDropDownOpen = true;
}
}
}
in WPF doesn't seem to work in the same way. I was wondering if anyone knew how to do this?
As pointed out in comments, I should say that the items in the ComboBox update as expected, but it doesn't drop down again in the WPF code.
Cheers,
EDIT: updated code