Programmatically selecting Items/Indexes in a ListBox

前端 未结 6 1900
情深已故
情深已故 2021-01-07 23:24

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

6条回答
  •  广开言路
    2021-01-08 00:15

    how to programmatically select multiple items in listbox in wpf

    foreach (var boundObject in objectsBoundToListBox)
    {
        ListBox.SelectedItems.Add(boundObject);
    }
    

提交回复
热议问题