Silverlight 之ComboBox控制元件選中項

暖楓無敵發表於2011-09-05
List<Book> books = e.Result;

this.ComboBox1.ItemsSource = books;
this.ComboBox1.DisplayMemberPath = "bookID";
this.ComboBox1.SelectedIndex = i;

// 遍歷有的 然後再取 序號 這樣的話才可以為combox 賦值

private int GetSelectedBookIndexByContent(string content)
{
   int result = 0;
   foreach (Book item in books)
   {
      if (item.bookID == content) 
      {
           break;
      }
      result ++;
   }
   return result;
}



相關文章