DataContext绑定
this.DataContext = new BindingAndValidationViewModel();
绑定到集合
ObservableCollection<ViewModel.Product> vProducts = new ObservableCollection<ViewModel.Product>(); public BindingProductObj() { InitializeComponent(); listBox.ItemsSource = vProducts; }
普通的集合只能是单向绑定,而继承了INotifyCollectionChanged的集合可以实现双向绑定,比如ObservableCollection、DataTable.DefaultView
标签:知识点,DataContext,ObservableCollection,绑定,new,WPF From: https://www.cnblogs.com/chixiner/p/17166444.html