Exemplo n.º 1
0
 public ProductViewModel(Product product) : base(product)
 {
     if (product.Group != null)
     {
         Group = new ProductGroupViewModel(product.Group);
         Group.Model.ModelChanged += OnModelChanged;
     }
 }
        public override void LoadItems(ObservableCollection <DataModel> source)
        {
            base.LoadItems(source);

            ProductGroupViewModel allGroup = NewItem(ProductGroup.All) as ProductGroupViewModel;

            Items.Insert(0, allGroup);
            SelectedItem = allGroup;

            View = (CollectionView)CollectionViewSource.GetDefaultView(Items);
        }
Exemplo n.º 3
0
 public override void OnModelChanged(object sender, DataAccess.ModelChangedEventArgs e)
 {
     if (Group != null && sender.Equals(Group.Model) && e.Type == DataAccess.ModelChangedEventArgs.EventType.Delete)
     {
         Group = null;
     }
     else if (e.Type == DataAccess.ModelChangedEventArgs.EventType.Update && e.Properties.Contains("Group"))
     {
         if ((sender as Product).Group == null)
         {
             Group = null;
         }
         else
         {
             Group = new ProductGroupViewModel(Model.Group);
         }
     }
     else if (e.Type == DataAccess.ModelChangedEventArgs.EventType.Update && (e.Properties.Contains("Price") || e.Properties.Contains("Tax")))
     {
         RaisePropertyChanged("TaxlessPrice");
         RaisePropertyChanged("TotalPrice");
     }
     base.OnModelChanged(sender, e);
 }
        public override DataViewModel NewItem(DataModel model)
        {
            ProductGroupViewModel viewmodel = new ProductGroupViewModel(model as ProductGroup);

            return(viewmodel);
        }