Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace WpfApplication1
- {
- public class recSet
- {
- public string Name { get; set; }
- public string Number { get; set; }
- public recSet(string na, string num)
- {
- Name = na;
- Number = num;
- }
- }
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- //create the list
- List<recSet> tmp = new List<recSet>();
- tmp.Add(new recSet("mark", "0123456789"));
- tmp.Add(new recSet("bob", "4578954425"));
- tmp.Add(new recSet("joe", "4587521665"));
- //bing the list to the combobox
- comboBox1.ItemsSource = tmp;
- //bind the properties
- comboBox1.DisplayMemberPath = "Name";
- comboBox1.SelectedValuePath = "Number";
- //default first element select
- comboBox1.SelectedIndex = 0;
- }
- }
- }
Add Comment
Please, Sign In to add comment