Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
745
Templating layout based on objects bound to the grid
posted

Hi guys!

I need to use the XamDataGrid like a matrix by binding it to the Rows collection of a DataTable.
The DataTable is filled with objects, and I want to use the property of an object to determine the layout (such as color, text, if it is read only or not) of the cell is is presented in.
Does anyone know how I can do that?

I have tried creating a style for the CellValuePresenter, but I'm not able to access my objects in any way using data binding because they are wrapped inside the DataRecord.DataItem, and the DataItem is my entire DataRow, not just the object at the [row,column] index that gets displayed in the XamDataGrid cell.
So how do I get access to the object that is displayed in a cell, and not the DataRecord itself?

Thanks!

  • 745
    Verified Answer
    posted

    After some research, I found the answer to my question in this post;

    http://forums.infragistics.com/forums/t/13120.aspx

    As I suspected, I had my data binding syntax wrong, which should have been (where ExistsAtTarget is a property exposed by my custom object)

    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Content.ExistsAtTarget}" Value="True">

    <Setter Property="Background" Value="Whitesmoke" TargetName="MainBorder"/>

    </DataTrigger>

    Thanks!