Categorized | Asp.net

Silverlight ComboBox binding with Dictionary.

Silverlight ComboBox binding with Dictionary.

<combobox x:name=”cboCountry” displaymemberpath=”Value” width=”264” canvas.left=”129” canvas.top=”172” SelectionChanged=”cboCountry_SelectionChanged/>

private void Page_Loaded(object sender, RoutedEventArgs e) {

Dictionary dict = new Dictionary();

dict.Add(1, “India”);

dict.Add(2, “USA”);

dict.Add(3, “FINLAND”);

cboCountry.ItemsSource = myDic;

}

private void cboCountry_SelectionChanged(object sender, SelectionChangedEventArgs e) {

KeyValuePair curItem = (KeyValuePair) cboCountry.SelectedItem;

MessageBox.Show(curItem.Key.ToString());

}

Leave a Reply


  • Popular
  • Latest
  • Comments
  • Tags
  • Subscribe

43,837
Unique
Visitors
Powered By Google Analytics