Home Forums WPF controls Xceed DataGrid for WPF GetContainerFromItem method works only for visible rows?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26284 |

    The following loop seems to return a DataRow object only if the row is visible
    (This is probably due to UI virtualization).

    foreach (object row in _dataGrid.Items)
    {
    Xceed.Wpf.DataGrid.DataRow currentRow = _dataGrid.GetContainerFromItem(row) as Xceed.Wpf.DataGrid.DataRow;
    }

    But is there anyway for me to retrieve a the full list of datarow(s)???

    Thanks

    Serene

    Imported from legacy forums. Posted by Serene (had 4527 views)

    Xceed Support
    Member
    Post count: 5658

    DataRows (Xceed.Wpf.DataGrid.DataRow) only exist when they are visible in the viewport (UI virtualization). There is no method to retrieve all the Xceed.Wpf.DataGrid.DataRows; however, you can retrieve the data items (usually System.Data.DataRow) through the DataGridControl.Items property.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 430 views)

    User (Old forums)
    Member
    Post count: 23064

    Unfortunately, my datagrid is binded to a Collection<Custom Objects>
    So Datagrid.Items will only return my Custom Object.

    What i need are Row objects to access their cells.
    Is there really no workaround for this?

    Serene

    Imported from legacy forums. Posted by Serene (had 535 views)

    Xceed Support
    Member
    Post count: 5658

    What do you need to access their cells for? Maybe there is another solution other than retrieving the container.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 239 views)

    User (Old forums)
    Member
    Post count: 23064

    I am trying to implement a export to CSV. And it is a configurable export – the user can select which columns he wishes to export.

    So I wanted to loop through the rows, and retrieve the cells of the columns applicable.

    It’s alright – I’ve implemented a work-around. I used reflection to retrieve the Properties from the object that I extract from Datagrid.Items.

    It might not be performance optimized 😛 but, i guess it has to do for now.

    Imported from legacy forums. Posted by Serene (had 4931 views)

    User (Old forums)
    Member
    Post count: 23064

    I have the same problem even after an year of this post.  Only change BringItemIntoView does not provide enough scalability to bring the cell in viewable area.  I ended up using reflection as well. As above reflection is not a satisfactory solution for performance and when display values are different from underlying values.

    Imported from legacy forums. Posted by Pritesh (had 2160 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.