Created
April 20, 2017 10:31
-
-
Save bjoerntx/0d91f80349939aa820a2836a6cd50003 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Order : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
// *** M E M B E R S *** | |
private ObservableCollection<ProductBlock> _productBlocks; | |
// *** P R O P E R T I E S *** | |
public int Total { get; set; } | |
public Customer Customer { get; set; } | |
public ObservableCollection<ProductBlock> ProductBlocks | |
{ | |
get { return _productBlocks; } | |
set { _productBlocks = value; } | |
} | |
// *** C O N S T R U C T O R *** | |
public Order() | |
{ | |
_productBlocks = new ObservableCollection<ProductBlock>(); | |
_productBlocks.CollectionChanged += _productBlocks_CollectionChanged; | |
} | |
// Update the Total, if new blocks are added | |
private void _productBlocks_CollectionChanged(object sender, | |
System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | |
{ | |
Total = 0; | |
foreach (ProductBlock block in _productBlocks) | |
{ | |
Total += block.BlockSum; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment