Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1170
XamDataGrid Bind to SummaryResults
posted

I'd like to display the sums of several fields in some Label UIElements, separate from the grid. I discovered that I can programmatically enable the sum calculation for the fields I need and bind my Label's Content to the SummaryResults, like so:

<Label Grid.Row="0" Grid.Column="1" Foreground="Blue" FontSize="9" Content="{Binding ElementName=DataGrid, Path=Records.SummaryResults[5].Value, Mode=OneWay}"/>

However there are a couple of issues. Ideally I would not show the summary row at all since it's a redundant display, but setting SummaryDisplayArea="None" results in the summary values never getting calculated - my Labels just remain blank. To compromise I thought I'd try "Bottom" so it would be less obtrusive, but then I realized that when the grid starts filling in and the summary row gets pushed below the visible vertical area my labels stop updating.

Is there a way to get either my ideal setup of a hidden summary row, or at least one that's not pinned to the top of the grid, but still pull from the SummaryResults collection for my bindings? Thanks.

Parents
  • 34430
    Verified Answer
    Offline posted

    Hello John,

    I have been investigating into the behavior you are seeing, and I have put together a sample project to test what you are seeing. I am also under the impression that this is a WPF question judging by the API, although it looks like this was created in the UWP forums. I will move the forum thread accordingly.

    I cannot seem to reproduce the behavior where the summaries don’t calculate if the summary row is out of view, and I am attaching a sample to demonstrate this.

    It is worth noting though, if you do not wish to see the summary area, you can use the following Style to remove the summary row:

    <Style TargetType="{x:Type ig:SummaryRecordPresenter}">
         <Setter Property="Height" Value="0" />
         <Setter Property="Width" Value="0" />
    </Style>

    Please let me know if you have any other questions or concerns on this matter.

    XDGBindSummaryResultDemo.zip

Reply Children
No Data