【问题标题】:XamDataGrid Collection ColumnXamDataGrid 集合列
【发布时间】:2010-06-14 15:17:47
【问题描述】:

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

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

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

【问题讨论】:

  • 我不熟悉 XamDataGrid,但是,我使用 WPF 工具包 Datagrid。我猜它们是相似的,整个网格通常绑定到一个DataTable。如果你给DataTable中的DataColumn赋值,你会得到这种类型的响应。

标签: wpf infragistics xamdatagrid


【解决方案1】:

我终于找到了答案。 我只是使用 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-11
    • 1970-01-01
    相关资源
    最近更新 更多