0

I'm displaying some read only data in a WPF DataGrid. The amount of data doesn't always fill the available space, and sometimes there is no data to show at all and the DataGrid is empty. However, I'd like the space to look like a spreadsheet regardless of how much data I've got. Is there a way to pad the DataGrid out with blank rows to make it look a bit more like a spreadsheet?

eoinmullan
  • 1,157
  • 1
  • 9
  • 32
  • possible duplicate of [Set a padding on dataGridCells in WPF](http://stackoverflow.com/questions/5246745/set-a-padding-on-datagridcells-in-wpf) – MoonKnight May 15 '14 at 11:26
  • 1
    No, the question is not about padding cells, but about filling datagrid area with dummy rows – amnezjak May 15 '14 at 11:28
  • What about using an `DataGridCellTemplate` which has a specified size and is always drawn, and using a binding for the `Content` if available? – Rachel May 15 '14 at 12:07
  • I think what you need is to add nulls to your collection of datarows that you're binding to. – Lee Louviere May 15 '14 at 16:13

1 Answers1

1

If your are binding data grid with a list fill class containing empty value in there property with which column is binded as per your requirement if the required data not come.

if required data come overwrite it.

Rajeev Ranjan
  • 1,006
  • 8
  • 18
  • thanks, but there are a few problems with that. 1) The number of rows needs to be known when the list is being populated and I'd prefer to keep view specific details in the view 2) If I want to add a row of new data then I need to clear the list and repopulate it 3) Columns that contain _int_ data will default to 0, I need them to be blank. – eoinmullan May 15 '14 at 12:06
  • 1) No it doesn't. Set a fixed amount, and then when you've replaced all the rows, adding more data will add new rows and you'll scroll. 2) Using a binding list instead of observable collection, then it will update on value changed instead of just item added. And if that doesn't work, you don't have to repopulate the whole collection, just remove a row and insert where you removed. 3) use Nullable<>. – Lee Louviere May 15 '14 at 16:16