void loadCategorieProduits() { cp = CategorieProduitORM.listeCategorieProduits(); myDataObject = new CategorieProduitViewModel(); //LIEN AVEC la VIEW /*listeCategorieProduits.ItemsSource = lp; // bind de la liste avec la source, permettant le binding.*/ }
private void OnPropertyChanged(string info) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(info)); this.PropertyChanged(this, new PropertyChangedEventArgs(info)); CategorieProduitORM.updateCategorieProduit(this); } }
private void btnAjouter(object sender, RoutedEventArgs e) { cp.Add(myDataObject); CategorieProduitORM.insertCategorieProduit(myDataObject); compteur = cp.Count(); // Comme on a inséré une CategorieProduit, on crée un nouvel objet CategorieProduitViewModel // Et on réatache tout ce qu'il faut pour que la vue soit propre myDataObject = new CategorieProduitViewModel(); // Comme le contexte des élément de la vue est encore l'ancien CategorieProduitViewModel, // On refait les liens entre age, slider, textbox, bouton et le nouveau CategorieProduitViewModel ComboBoxProduit.DataContext = myDataObject; ComboBoxCategorie.DataContext = myDataObject; }