How to add footer in datagrid WPF RRS feed


All replies

  • AHOI

    Modify the style of the datagrid an a section ("footer") after the itemspresenter.

    Monday, May 3, 2010 6:32 AM
  • HI,




    <dg:DataGrid Name="grdViewOrder" ItemsSource="{Binding}" AutoGenerateColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserAddRows="False" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,0,-9,0">






    <dg:DataGridTextColumn Width="Auto" Header="Quantity" Binding="{Binding Path=Quantity}" CanUserReorder="False" CanUserResize="False" IsReadOnly="True" />



    <dg:DataGridTextColumn Width="80" Header="Item" Binding="{Binding Path=ItemName}" CanUserReorder="False" CanUserResize="False" IsReadOnly="True" />



    <dg:DataGridTextColumn Width="80" Header="Item Price" Binding="{Binding Path=Price}" CanUserReorder="False" CanUserResize="False" IsReadOnly="True" />



    <dg:DataGridTextColumn Header="Total Price" Binding="{Binding Path=TotalPrice}" CanUserReorder="False" CanUserResize="False" IsReadOnly="True" Width="*" />










    Can u please explain with an example?


    Monday, May 3, 2010 7:30 PM
  • You have to modify the control template of the datagrid to add in a footer row after the ItemsPresenter.  The itemspresenter is the object that outputs all the rows.  Then you would have to use valueconverters to perform the aggregations for the column.

    Here is an alternative method of using multiple datagrids.  example done with the datagrid from the toolkit:


    and updated for 4.0


    • Proposed as answer by Alexander Yudakov Tuesday, May 4, 2010 10:00 AM
    • Marked as answer by Jie Bao Monday, May 10, 2010 1:19 AM
    Tuesday, May 4, 2010 2:18 AM