Back to Devexpress

RowData.Row Property

wpf-devexpress-dot-xpf-dot-grid-dot-rowdata.md

latest5.5 KB
Original Source

RowData.Row Property

Gets a row object that corresponds to the row.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public object Row { get; set; }
vb
Public Property Row As Object

Property Value

TypeDescription
Object

An object in a data source that corresponds to the current row.

|

Remarks

Row objects are records in a data source. For instance, a DataRow object is a record in a DataTable.

Row elements contain RowData objects in their DataContext.

Use the following binding paths to access cell values and ViewModel properties:

  • Row.[YourPropertyName] - access a property of an object in the ItemsSource collection;
  • DataContext.[FieldName] - access a column value;
  • View.DataContext.[YourPropertyName] - access a property in a grid’s ViewModel.

View Example: Build Binding Paths in WPF Data Grid Rows

The following code snippets (auto-collected from DevExpress Examples) contain references to the Row property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-change-cell-template-based-on-custom-logic/CS/Window1.xaml.cs#L57

csharp
EditGridCellData data = (EditGridCellData)item;
var dataItem = data.RowData.Row as TestData;
return dataItem == null || string.IsNullOrEmpty(dataItem.Editor) ? null : (DataTemplate)((FrameworkElement)container).FindResource(dataItem.Editor);

wpf-data-grid-create-custom-gridcontrol-that-displays-horizontal-columns/CS/dxExample/VGrid/VerticalGridControl.cs#L121

csharp
public override DataTemplate SelectTemplate(object item, DependencyObject container) {
    var row = (VerticalRow)((EditGridCellData)item).RowData.Row;
    return (row.CellTemplate != null) ? row.CellTemplate : base.SelectTemplate(item, container);

how-to-dynamically-select-a-row-details-template-with-datatemplateselector-e20021/CS/Grid_RowDetailsTemplateSelector/RowDetailsTemplateSelector.cs#L12

csharp
if (row != null) {
    Person person = row.Row as Person;
    if (person != null)

wpf-data-grid-change-cell-template-based-on-custom-logic/VB/Window1.xaml.vb#L69

vb
Dim data As EditGridCellData = CType(item, EditGridCellData)
Dim dataItem = TryCast(data.RowData.Row, TestData)
Return If(dataItem Is Nothing OrElse String.IsNullOrEmpty(dataItem.Editor), Nothing, CType(CType(container, FrameworkElement).FindResource(dataItem.Editor), DataTemplate))

wpf-data-grid-create-custom-gridcontrol-that-displays-horizontal-columns/VB/dxExample/VGrid/VerticalGridControl.vb#L150

vb
Public Overrides Function SelectTemplate(ByVal item As Object, ByVal container As DependencyObject) As DataTemplate
    Dim row = DirectCast(DirectCast(item, EditGridCellData).RowData.Row, VerticalRow)
    Return If(row.CellTemplate IsNot Nothing, row.CellTemplate, MyBase.SelectTemplate(item, container))

how-to-dynamically-select-a-row-details-template-with-datatemplateselector-e20021/VB/Grid_RowDetailsTemplateSelector/RowDetailsTemplateSelector.vb#L16

vb
If row IsNot Nothing Then
    Dim _person As Person = TryCast(row.Row, Person)
    If _person IsNot Nothing Then

See Also

GetRow(Int32)

RowData Class

RowData Members

DevExpress.Xpf.Grid Namespace