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
215
Add a fixed row to the bottom of a XamDataGrid?
posted

Hi,

I have custom content that I would like to display in a fixed row at the bottom of my datagrids. It would be very similar to the SummaryResultsPresenter area, however I don't want it to be fixed to any record columns. It needs to span the entire width of the datagrid and always be fixed as the last row of the datagrid.

We currently define our xamdatagrids in code like this:

------------------------------------------------------------------------------------------------------------

private void OurDataGrid_Loaded(object sender, RoutedEventArgs e)
{
this.myDataGrid = sender as XamDataGrid;
OurDataGrid myProjectGrid = sender as OurDataGrid;

Grid grid = Utilities.GetDescendantFromType(this.myDataGrid, typeof(Grid), false) as Grid;

if (grid != null && grid.Children.Count < 2)
{
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });

Grid dynamicGrid = new Grid();

RowDefinition gridRow1 = new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) };
RowDefinition gridRow2 = new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) };
RowDefinition gridRow3 = new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) };
RowDefinition gridRow4 = new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) };
dynamicGrid.RowDefinitions.Add(gridRow1);
dynamicGrid.RowDefinitions.Add(gridRow2);
dynamicGrid.RowDefinitions.Add(gridRow3);
dynamicGrid.RowDefinitions.Add(gridRow4);

Grid.SetRow(this.lblFilteredItems, 0);
dynamicGrid.Children.Add(this.lblFilteredItems);

Grid.SetRow(this.searchBar, 1);
dynamicGrid.Children.Add(this.searchBar);

grid.Children.Add(dynamicGrid);

summaryFooterRow.Template = (ControlTemplate)this.TryFindResource("ControlTemplate");
Grid.SetRow(this.summaryFooterRow, 3);
//grid.Children.Add(this.summaryFooterRow);
}

------------------------------------------------------------------------------------------------------------

The row I would like to set as fixed to the bottom is called summaryFooterRow. The problem is that the row I am setting above that row (grid.Children.Add(dynamicGrid);) could be 5 or 5,000 rows of data. Right now summaryFooterRow is displaying above the dynamic grid.

Just to be clear, we have a total of 4 rows, (1) a filter row, (2) a searchbox row, (3) the dynamic data rows, and (4) the summaryFooterRow that I am trying to fix to the bottom.

Is there a way to set summaryFooterRow as the 4th row and the dynamicGrid rows as the 3rd row? Or is there a better way to fix it to the bottom of the datagrid than the way I am trying to do it?

Thanks in advance for your help!

-Jeff