Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            var data = new List <HocSinh> {
                new HocSinh {
                    MSSV = 20172605, Name = "Le Quang Huy"
                },
                new HocSinh {
                    MSSV = 20172538, Name = "Nguyen Thi Hien"
                },
            };

            var sp = new StackPanel
            {
                Background  = Brushes.AliceBlue,
                Orientation = Orientation.Horizontal,
            };
            var mcb = new MyComboBox();

            foreach (var item in data)
            {
                var mcbi = new MyComboBoxItem(item, "Name", "MSSV");
                mcb.Add(mcbi);
            }

            var bt = new Button
            {
                Content = "Submit",
                Width   = 50,
                Height  = 25,
            };

            bt.Click += (s, e) =>
            {
                MessageBox.Show(mcb.SelectedItem.ReturnValue.ToString());
            };

            sp.Children.Add(mcb);
            sp.Children.Add(bt);
            Content = sp;
        }