views:

60

answers:

1

Is there a way to bind to a collection column in a XamDataGrid DataSource?

What i am trying to do is to show all the items of the specific column collection in a single grid field. (using the appropriate templates).

Hope it makes sense to you all. Let me know if you need me to clarify things a little bit more.

A: 

I finally found the answer. I just used a Wrapper class to host the collection and bind to the column to the Wrapper class property instead of the collection property.

After that, making the appropriate template is very easy.

Here is an example:

    <Style x:Key="ValidationsStyle" TargetType="{x:Type igDP:CellValuePresenter}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                <ContentControl DataContext="{TemplateBinding Value}">
                    <ItemsControl ItemsSource="{Binding Validations}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding ValidationName}" />
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ContentControl>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Entrodus