Show “No record found” message on a WPF DataGrid when it's empty

后端 未结 4 1682
陌清茗
陌清茗 2020-12-18 22:13

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 attac

4条回答
  •  醉酒成梦
    2020-12-18 22:58

    Finally I am able to findout the way.

    1. When the grid in empty, add a default row on grid
    2. Create a RowDetailTemplate which contain a text block with a message "No Record Found"

      
          
              
                  
              
          
      
      
    3. 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.

提交回复
热议问题