Silverlight ComboBox binding with Dictionary.

Posted In Asp.net - By admin On Monday, October 5th, 2009 With 0 Comments

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());

}

About -

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>