I have a form with a few controls on it; some text boxes that are databound to a private form object's properties (Financial) and a DevExpress GridControl that is databound to a BindingList(of Fee) (Fees) property on the same Financial object. One of the properties on Financial is a readonly property that calculates some data based on other properties of the Financial and Fees (MonthlyCosts). Both Financial and Fee implement INotifyPropertyChanged.
The problem that I am having is that the textbox that is bound to that MonthlyCosts property does not update when changes are made to the GridControl. If I change the cost of a fee in the GridControl, then change a textbox value (Margin) that is also used in that calculation, the textbox with the calculated value will only update after I change the Margin.
Some of the related code is shown below:
Public Class Financial
Inherits BindableBase ' helper for INotifyPropertyChanged
Public Property Margin As Decimal
Get
return _margin
End Get
Set
SetProperty() ' INotifyPropertyChanged stuff
End Set
End Property
Public ReadOnly Property Fees As BindingList(Of Fee)
Public ReadOnly Property Total as Decimal
Get
return Fees.Sum(Function(fee) fee.Amount) / (1 - Margin)
End Get
End Property
End Class
Public Class Fee
Inherits BindableBase ' helper for INotifyPropertyChanged
Public Property Amount as Decimal
End Class
In the form:
' Setup the databindings
Margin.DataBindings.Add("EditValue", Financial, NameOf(Financial.Margin))
FeeGrid.DataBindings.Add("DataSource", Financial, NameOf(Financial.Fees))
Total.DataBindings.Add("EditValue", Financial, NameOf(Financial.Total))
The databindings all seem to work fine, except in the case of changing the Fees doesn't change the Total textbox. If I put a button that pops up the Total property in a MessageBox, it reports the correct Total, but the textbox is not updating. It seems like the NotifyPropertyChanged on the Fee object isn't getting propagated up through the BindingList to the Form to tell it to refresh the Total textbox.