Is there a way to get an iteratable collection of all the cells in a DataGrid regardless of whether they are selected or not
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
For the sake of convenience (not necessarily performance), you can populate your data (including all cells from all column and rows) from your DataGrid to a single DataTable, which provides functions to help manipulate your data such as iteration, filtering, sorting etc.
You can subsequently convert any of a specific column to a collection or list using generics in as short as one line of code. See how-do-you-convert-a-datatable-into-a-generic-list:
It saves you from writing loops.
If you mean
DataGridCell
s you could use Vincent Sibals helper functions to iterate over all rowsDataGrid.Items
and columnsDataGrid.Columns
.Edit
If grid is your DataGrid you get a list of all DataGridCells like this:
To fix the error thrown by the line...
Add this routine: