In WPF, I\'d like to set the selected indexes of a System.Windows.Controls.ListBox
I best way I\'ve found so far is to remove all the items from the control, insert
One way you can do this is to add a Selected field to your data object. Then you need to overide the default listboxitem style and bind the isselected property to the Selected property in your object. Then you just need to go through your data items and update the Selected value.
If you don't implement that Selected property as a dependency property, you need your class to implented the INotifyPropertyChanged interface and raise the propertychanged event when you set the value.