Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created April 20, 2017 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/0d91f80349939aa820a2836a6cd50003 to your computer and use it in GitHub Desktop.
Save bjoerntx/0d91f80349939aa820a2836a6cd50003 to your computer and use it in GitHub Desktop.
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