How to iterate over the rows and cells in an Xceed WPF DataGrid

I found this handy code on the Xceed forums today. See http://xceed.com/CS/forums/permalink/26496/26518/ShowThread.aspx#26518

            foreach (object item in thisDataGrid1.Items)
            {
                Dispatcher.BeginInvoke(new Action<object>(DoRow), DispatcherPriority.ApplicationIdle, item);
            }

        private void DoRow(object item)
        {
            Xceed.Wpf.DataGrid.DataRow row = this.DataGrid1.GetContainerFromItem(item) as Xceed.Wpf.DataGrid.DataRow;
            if (row != null)
            {
                foreach (Xceed.Wpf.DataGrid.DataCell c in row.Cells)
                {
                    if (c != null)
                    {
                        //Do something to the cell
                    }
                }
            }
        }

No comments:

Post a Comment