Home Forums WPF controls Xceed DataGrid for WPF Row Binding

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23968 |

    I would like to understand if there is a way to bind row properties present in an XML data island to a grid. Here is sample XML which shows that there is a Background property set for a row:

    <Row Background=”Red”>
    <column0>411</column0>
    <column1>Sloppy</column1>
    <column2>Medium</column2>
    <column3>Unassigned</column3>
    </Row>

    I would like to generate this completely in XAML with no dependency on code-behind. Thanks for any tips.

    Imported from legacy forums. Posted by Marty (had 775 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marty,

    Using the code in your last post it seems like a relative syntax works Background=”{Binding XPath=../@Background}”/>.

    Rich

    <code>
    <xcdg:Column FieldName=”column0″ Title=”ID” Width=”50″ DisplayMemberBinding=”{Binding XPath=column0}”>

    <xcdg:Column.CellContentTemplate>

    <DataTemplate>

    <TextBlock Text=”{Binding XPath=.,Mode=OneWay}” Background=”{Binding XPath=../@Background}”/>

    </DataTemplate>

    </xcdg:Column.CellContentTemplate>

    </xcdg:Column>

    </code>

    Imported from legacy forums. Posted by Richard (had 319 views)

    User (Old forums)
    Member
    Post count: 23064

    That does work fine for cell binding. As you can see, the binding in this example will work out to be /Rows/Row/Column0/@Background.

    But what I am looking for is to bind the DataRow together with a property that works out to /Rows/Row/@Background.

    We have an option in our legacy system that says “highlight the entire row” using some attribute. Right now my implementation is to take that option and chug through all the cells to turn on the attribute. But is seems it would be more efficient if I could just turn on the ROW level attribute once.

    Thanks.

    Marty

    Imported from legacy forums. Posted by Marty (had 603 views)

    User (Old forums)
    Member
    Post count: 23064

    OK, I’d like to know how to do that too 🙂

    The “Example 4: Providing a DataRow template” from the doc’s looks interesting…

    http://doc.xceedsoft.com/products/XceedWpfDataGrid/Advanced%20Concepts%20-%20How-to.html

    When I get some time I’ll be looking at it more closely to see replacing the DataRow template is the way to go for situations like yours.

    Imported from legacy forums. Posted by Richard (had 265 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marty,

    You can create a Style that sets the background on the entire row as follows:
    <Style TargetType=”{x:Type xcdg:DataRow}”>
    <Setter Property=”Background” Value=”{Binding XPath=./@Background}” />
    </Style>

    Also to clarify my earlier post and make sure we are on the same page, the ../@Background XPath does pull from Rows/Row/@Background. The syntax from the previous post is repeated here:

    <TextBlock Text=”{Binding XPath=.,Mode=OneWay}”
    Background=”{Binding XPath=../@Background}”/>

    Imported from legacy forums. Posted by Richard (had 4236 views)

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