If you don't want to trigger SelectionChanged Event but still want to update the content, you can unsubscribe that event handler and use data binding. Try this in your xaml:
<local:MyCombox x:Name="mycombo" Height="60" Width="200" ItemsSource="{Binding Path=MyCollection}" SelectedItem="{Binding Path=MyItem}" SelectionChanged="mycombo_SelectionChanged">
</local:MyCombox >
and below in your cs file:
public partial class MainWindow : Window
{
public List<string> MyCollection { get; set; }
public string MyItem { get; set; }
public MainWindow()
{
InitializeComponent();
MyItem = "test";
MyCollection = new List<string>();
MyCollection.Add(MyItem);
MyItem = "test1";
MyCollection.Add(MyItem);
this.DataContext = this;
mycombo.SelectionChanged -= mycombo_SelectionChanged;
mycombo.SelectedIndex = 1;
}
private void mycombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
I have created a sample project here. You will find SelectionChanged
Event will not be triggered. Actually you even don't need to customize a ComboBox.
However, If this event does not cause a performance issue, it is still recommended that you use it, as these events are designed like this in WPF.