I have a ComboBox:
<ComboBox Name="drpRoute" SelectionChanged="drpRoute_SelectionChanged" />
And I installed the list items in the code behind the 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 SelectedIndex, the event SelectionChangedfires.
How can I install ItemSourceand install SelectedIndexwithout triggering an event SelectionChanged?
I am new to WPF, but of course it should not be as complicated as it seems? or am I missing something here?
source
share