Home Forums WPF controls Xceed DataGrid for WPF How to get DataItem from DataRow

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #26818 |


    I have set up a double click event handler on my grid’s datarows.

    I can then cast the sender-object in my event handler to DataRow.

    But how do I get hold of the DataItem the DataRow is displaying?


    DataItem = DataRow.DataContext


    seems to be a solution.

    Is this the preferred way? Is this a stable solution?

    Or is there another way?




    Imported from legacy forums. Posted by Michael (had 630 views)

    Xceed Support
    Post count: 5658

    That is indeed a valid method and we don`t plan on changing this.

    If you need a more explicit way of retrieving the data item, there is another interface that exists, one that goes through the DataRow`s DataGridContext.

    DataGridContext rowContext = DataGridControl.GetDataGridContext( dataRow );

    object dataItem = rowContext.GetItemFromContainer( dataRow );

    The main advantage of this method is that you can pass ANY UI element that is part of the VisualTree of the Row or Cell to the GetItemFromContainer() method and that the appropriate Data Item will be returned.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 2308 views)

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