WPF里关于列表控件的数据绑定后的显示问题(在线等)
一个wpf窗体上,2个按钮1个ComboBox和1个ListBox:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;using System.Collections;namespace comboboxDEMO{ /// <summary> /// Window2.xaml 的交互逻辑 /// </summary> public partial class Window2 : Window { ArrayList myAL; public Window2() { InitializeComponent(); myAL = new ArrayList(); myAL.Add("Hello"); myAL.Add("World"); myAL.Add("!"); comboBox1.ItemsSource = myAL; myAL.Add("2"); myAL.Add("3"); myAL.Add("4"); listBox1.ItemsSource = myAL; } private void button1_Click(object sender, RoutedEventArgs e) { myAL.Add("5"); myAL.Add("6"); myAL.Add("7"); } private void button2_Click(object sender, RoutedEventArgs e) { myAL.Add("15"); myAL.Add("16"); myAL.Add("17"); } }}