Guest User

Untitled

a guest
Feb 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. namespace WpfApplication1
  2. {
  3. public class recSet
  4. {
  5. public string Name { get; set; }
  6. public string Number { get; set; }
  7.  
  8. public recSet(string na, string num)
  9. {
  10. Name = na;
  11. Number = num;
  12. }
  13. }
  14.  
  15. /// <summary>
  16. /// Interaction logic for MainWindow.xaml
  17. /// </summary>
  18. public partial class MainWindow : Window
  19. {
  20. public MainWindow()
  21. {
  22. InitializeComponent();
  23.  
  24. //create the list
  25. List<recSet> tmp = new List<recSet>();
  26.  
  27. tmp.Add(new recSet("mark", "0123456789"));
  28. tmp.Add(new recSet("bob", "4578954425"));
  29. tmp.Add(new recSet("joe", "4587521665"));
  30.  
  31. //bing the list to the combobox
  32. comboBox1.ItemsSource = tmp;
  33.  
  34. //bind the properties
  35. comboBox1.DisplayMemberPath = "Name";
  36. comboBox1.SelectedValuePath = "Number";
  37.  
  38. //default first element select
  39. comboBox1.SelectedIndex = 0;
  40. }
  41. }
  42. }
Add Comment
Please, Sign In to add comment