public MainWindow()
        {
            StoreDB storeDb = new StoreDB();

            InitializeComponent();
            products = storeDb.GetProducts();

            this.DataContext     = products;
            view                 = (ListCollectionView)CollectionViewSource.GetDefaultView(this.DataContext);
            view.CurrentChanged += new EventHandler(view_CurrentChanged);

            lstProducts.ItemsSource = products;
        }
示例#2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     products = new ObservableCollection <Product>(StoreDB.GetProducts());
     lstProducts.ItemsSource = products;
     var a = CollectionViewSource.GetDefaultView(lstProducts.ItemsSource);
 }