I have a ComboBox:
<ComboBox Name="drpRoute" SelectionChanged="drpRoute_SelectionChanged" />
And I set the list items in the code behind file:
public ClientReports()
{
InitializeComponent();
drpRoute.AddSelect(...listofcomboxitemshere....)
}
public static class ControlHelpers
{
public static ComboBox AddSelect(this ComboBox comboBox, IList<ComboBoxItem> source)
{
source.Insert(0, new ComboBoxItem { Content = " - select - "});
comboBox.ItemsSource = source;
comboBox.SelectedIndex = 0;
return comboBox;
}
}
For some reason, when I set the SelectedIndex
, the SelectionChanged
event get's fired.
How on earth do I set the ItemSource
and set the SelectedIndex
without firing the SelectionChanged
event?
I am new to WPF, but surely it should not be as complicated as it seems? or am I missing something here?