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 (see RowData.Row);DataContext.[FieldName]- access a column value in Server Mode, access an unbound column value (see RowData.DataContext);View.DataContext.[YourPropertyName]- access a property in the grid's ViewModel (see RowDataBase.View).
The bindings used in this example work as follows:
- Bind the row
Backgroundto theColorproperty stored at the item level:
<Trigger Property="SelectionState" Value="None">
<Setter Property="Background" Value="{Binding Row.Color, Converter={dxmvvm:ColorToBrushConverter}}" />
</Trigger>- Highlight a row when the
HighlightVisitedproperty of the grid'sViewModeland theVisitedcolumn value aretrue:
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding View.DataContext.HighlightVisited}" Value="True" />
<Condition Binding="{Binding DataContext.Visited}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="TextElement.FontStyle" Value="Italic" />
<Setter Property="TextElement.FontWeight" Value="Bold" />
</MultiDataTrigger>- Build Binding Paths in WPF Data Grid Cells
- WPF Data Grid - Select a Row Template Based on Custom Logic
(you will be redirected to DevExpress.com to submit your response)
