0

有没有办法绑定到 XamDataGrid 数据源中的集合列?

我要做的是在单个网格字段中显示特定列集合的所有项目。(使用适当的模板)。

希望对大家有意义。如果您需要我进一步澄清一些事情,请告诉我。

4

1 回答 1

0

我终于找到了答案。我只是使用 Wrapper 类来托管集合并将列绑定到 Wrapper 类属性而不是集合属性。

之后,制作合适的模板就很容易了。

这是一个例子:

    <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>
于 2010-06-14T15:53:28.560 回答