Silverlight / WPF - Get data sum from data class of tableadapter to bind to xaml/wpf form

Asked By David on 19-Jan-13 05:12 PM
 Hi All

 I have been struggling to get the Data totals from my dataset/tableadapter so I have  Created a property class for the total in which I want to show  the totals  of the other 6 properties in raise PropertyChanged event and bind it to xaml form to show a live update of the running total when entering data/numbers only into the text boxes on my user form.
 How can i code to pick these sums up?
Thanks

David
Robbe Morris replied to David on 19-Jan-13 05:17 PM
Create a Total column on your data class that adds up the other property values in its Get.  Create a Set that is empy.

In each of those other properties, raise the PropertyChanged handler on the Total property in its own Set along with the PropertyChanged event on itself.  Binding in XAML will take care of the rest.
David replied to Robbe Morris on 20-Jan-13 09:22 AM
 Hi Robbie

 I have created a property called total   How do I Create this Get for this property and where do I do it
Thanks

David

Robbe Morris replied to David on 20-Jan-13 10:36 AM

public double Total
{ 
    get
    {
     return this.ColA + this.ColB + this.ColC;
    }
    set
  {

    }
}

David replied to Robbe Morris on 20-Jan-13 10:59 AM
 Hi Robbie

 I have coverted to vb.net  for xaml vb but 2 property from dataset have lines under
 Please what am I doing wrong.
 Thanks David

Public


Property Total() As Double

Get

Return Me.txtH1SC + Me.TxtH2SC + Me.txtH3SC

End Get

Set(ByVal value As Double)

End Set

End Property

David replied to Robbe Morris on 21-Jan-13 05:00 PM

 Hi Robbie I am still finding it hard to get/set its not part of my coding 
I have this class for total like you suggested

 Partial      Class PlayedCoursesDataSet

Partial Class COURSES_PLAYEDDataTable

Private Sub COURSES_PLAYEDDataTable_ColumnChanging(ByVal sender As System.Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging

If (e.Column.ColumnName = Me.TotalColumn.ColumnName) Then

'Add user code here

End If

End Sub

End Class

End


Class

 What goes in the Add user code here please

Thanks David