I\'m running into a small problem where I\'m trying to bind a DataTextColumn of a DataGrid to a Calculated Field.
WPF
I'm assuming Student implements INotifyPropertyChanged. what you have to do is to register to the PropertyChanged Event for LodgingCosts + RegistrationCosts + TravelCosts + DiningCosts, and raise the PropertyChanged event for TotalCosts.
public partial class Student
{
public Decimal TotalCosts
{
get { return (LodgingCosts + RegistrationCosts + TravelCosts + DiningCosts); }
}
public Student()
{
this.PropertyChanged += new PropertyChangedEventHandler(Student_PropertyChanged);
}
void Student_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "LodgingCosts" ||
e.PropertyName == "RegistrationCosts" ||
e.PropertyName == "TravelCosts" ||
e.PropertyName == "DiningCosts")
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("TotalCosts"));
}
}
}