Advertisement
Guest User

ShoppingListViewModel.cs

a guest
Sep 12th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using Margo.Data;
  2. using Margo.UI.Utilities;
  3. using System;
  4. using System.Data;
  5.  
  6. namespace Margo.UI.ViewModel
  7. {
  8.     public class ShoppingListViewModel : BaseViewModel
  9.     {
  10.         private DataAccess _dataAccess = new DataAccess();
  11.         private DataTable _shoppingList;
  12.  
  13.         public BaseViewModel ViewModel { get; set; }
  14.  
  15.         public DataTable ShoppingList
  16.         {
  17.             get { return _shoppingList; }
  18.             private set
  19.             {
  20.                 _shoppingList = value;
  21.                 OnPropertyChanged(nameof(ShoppingList));
  22.             }
  23.         }
  24.  
  25.         public RelayCommand AddProductCommand { get; private set; }
  26.  
  27.         public ShoppingListViewModel()
  28.         {
  29.             _dataAccess.ConnectToDatabase();
  30.             ShoppingList = _dataAccess.ShoppingList;
  31.             AddProductCommand = new RelayCommand(OnAddProduct);
  32.         }
  33.  
  34.         public event Action AddProductRequested = delegate { };
  35.  
  36.         private void OnAddProduct()
  37.         {
  38.             AddProductRequested();
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement