Search code examples
c#wpfdata-bindingdevexpress

Bind to current row data in a column display template


In the devexpress grid below how do I bind to the current row data in the column template and use a converter object.

<dxg:GridControl ItemsSource="{Binding Data}" FontSize="16">
    <dxg:GridControl.View>
        <dxg:TableView AutoWidth="True" AllowEditing="False" AllowColumnMoving="False" NavigationStyle="None" ShowIndicator="False" AllowColumnFiltering="False" ShowGroupPanel="False" AllowPerPixelScrolling="True" AllowBestFit="True"/>
    </dxg:GridControl.View>
    <dxg:GridControl.Columns>
           
        <dxg:GridColumn Header="Field1" FieldName="Field1">
            <dxg:GridColumn.DisplayTemplate>
                <ControlTemplate>
    <!-- how do i bind to current row data-->
                </ControlTemplate>
            </dxg:GridColumn.DisplayTemplate>
        </dxg:GridColumn>
    </dxg:GridControl.Columns>
</dxg:GridControl>

Solution

  • <ControlTemplate>
        <TextBlock Text="{Binding Path=RowData.Row.FieldName}">
        </TextBlock>
    </ControlTemplate>