Get datagrid rows

后端 未结 2 621
慢半拍i
慢半拍i 2021-01-02 02:50

How can I get the list of rows in the DataGrid? Not the bound items, but the DataGridRows list.

I need to control the visibility of these rows and it\'

2条回答
  •  死守一世寂寞
    2021-01-02 03:11

    I recommend defining a Style for DataGridRow that will have its Visibility bound to whether it should be displayed or not. Just iterating through the rows won't be enough, as I mentioned in @RV1987's answer.

    
        
            
        
    
    

    EDIT:

    What you bind to depends on where you hold the information of whether or not you should display the row. For example, if each data object in your bound collection has a bool ShouldBeDisplayed property, you would have something like this:

    
        
            
    
            
        
    
    

提交回复
热议问题