WPF DataGrid RowHeader databinding

前端 未结 6 2066
孤城傲影
孤城傲影 2020-12-05 13:17

I have a DataGrid, bound to a DataTable. I want to display text in the RowHeader, to achieve something like this:

         Col0      Col1      Col2      Col3         


        
6条回答
  •  眼角桃花
    2020-12-05 13:53

    Just FYI, if you bind directly to a data table, then this binding text worked for me:

    {Binding RelativeSource={RelativeSource Mode=FindAncestor, 
                                      AncestorType={x:Type DataGridRow}}, 
                                      Path=Item.Row.Header}
    

    Poked around a little bit and found that in the Item.Row.Header path, the path starts at the DataGridRow, the Item takes you to the DataGridView, and the Row takes you to the DataRow.

    Again, if you bind directly to the data table.

提交回复
热议问题