How can I set the selected items in a WPF ListView programmatically?
Basically, I have a List<SomeEntity>
and a ListView that is bound to another List<SomeEntity>
. I need to mark the items that exist on the first list as selected.
var lv = yourListView;
lv.SelectedItems.Clear();
foreach(var item in selection)
lv.SelectedItems.Add(item);
http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.selecteditems.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With