How to get the number of columns and rows from a table in a DataGrid (WPF)? in the forms it was simple: RowCount and ColumnCount but what about wpf?
- In WPF, you should not want to know the parameters of your data and visual element. The parameters of your data need to look at the VM. - VladD
- @VladD what is a VM? Recently, only tears from the forms. - Sergey
- Well, you should read about MVVM. In short, when you separate the content from the presentation, the VM is the content, and the presentation is your XAML and its code-behind. - VladD
- @VladD thanks! - Sergey
|
1 answer
Almost the same (directly):
int count_row = dataGrid.Items.Count; int count_col = dataGrid.Items[0].Cells.Count; Via DataSource:
int count_row = ((DataTable)dataGrid.DataSource).Rows.Count; int count_col = ((DataTable)dataGrid.DataSource).Columns.Count; Here's a similar question: https://stackoverflow.com/questions/838679/row-and-column-count-of-data-grid-in-c-sharp
|