選定值我最初在listBox
添加一些字符串對象,事後我想設置所選的項目:設置列表框的WPF
List <string> CustName = new List<string>();
....///add items to CustName///...
listBox1.ItemsSource = CustName;
string selection = "myselection" ///this string is contained in CustName
listBox1.SelectedValue = selection;
但是塔上面不起作用作用似乎是選擇的項目是該listBox
而不是一個我嘗試設置的第一項...
您是否嘗試過'listBox1.SelectedIndex = indexOfMySelection'? – 2014-08-29 10:41:01