If there is no record available, I want to add a TextBlock
on data grid, below the header, showing the message "No Record Found."
Consider the attached image for reference.
If there is no record available, I want to add a TextBlock
on data grid, below the header, showing the message "No Record Found."
Consider the attached image for reference.
I find that it is easy to center a text block over the grid and set its visibility based on the number of rows. I am usually using MVVM and will bind the visibility to a View Model property:
It will show/hide based on your collection/list count.
Finally I am able to findout the way.
Create a RowDetailTemplate which contain a text block with a message "No Record Found"
Set the style on datagrid
By default (record available on datagrid) row detail template will be collapsed.
DataTrigger that checks CLR poperty, if it is false then show the row detail template.
The reason for setting the rowheight as 0 to hide the default row which we haved added on 1st step.
Its been a long time since the question has been posted. But I thought this might be useful to someone else.
For simplicity purpose I have set AutoGenerateColumns="True". Please define the columns. This way when a empty datasource is bound, the column names will be shown along with 'Empty row' message.