Question

How can i get the total of a field in a XamDataGrid? I want to show the sum of all records' $ amounts in a textbox NOT in the grid itself. Here's how i did this for the number of items in the grid, which works:

<Label Content="Total Line Items"/>
            <TextBox Text="{Binding ElementName=xamDataGrid1, Path=Records.Count, Mode=OneWay}" Grid.Column="1" />

So how can i sum a certain field? Is it possible to do anything like:

        <Label Content="Total Salaries: " Grid.Column="2" />
        <TextBox Grid.Column="3" BorderBrush="Red" Text="{Binding ElementName=xamDataGrid1, Path=**SUM(SALARYFIELD)**, Mode=OneWay}"/>

I do not want the SummaryDefintions method (I know how to do that already) and i must not refer to the grid in code-behind etc. What can i put in the binding, or what can i replace SUM(SALARYFIELD) with to make this work?

Was it helpful?

Solution

I found the answer i was looking for. Had to involve XamDataGrid's Summary definitions, but I can not show them and then bind to their data as below:

<TextBox Text="{Binding ElementName=xamDataGrid1, Path=Records.SummaryResults[1].Value, StringFormat=C, Mode=OneWay}"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top