使用 XamDataGrid 实现行详细信息

发布于 2024-11-19 13:28:24 字数 960 浏览 2 评论 0原文

现在我正在尝试将 WPF DataGrid 的 RowDetails 功能之类的功能实现到 XamDataGrid 中。我尝试做的事情(到目前为止失败):

1.)替换 ExpandableFieldRecordPresenterStyle

在 FieldSettings 中,我用我自己的样式替换 ExpandableFieldRecordPresenterStyle 这种样式位于窗口资源中,并将 Template / TemplateGridView (都尝试过)属性设置为我自己的 DataTemplate / ControlTemplate (都尝试过)。

这不起作用,尽管样式已设置,但我没有看到视觉表现有任何变化。

2.) 替换 DataRecordPresenterStyle

在 FieldLayoutSettings 中,我将 DataRecordPresenterStyle 替换为我自己的样式。这与之前的方法相同并且有效。但是,现在我必须重新实现原始的 DataPresenterStyle,因为我只想添加行详细信息控件,但其余部分保持不变。这就是我现在陷入困境的地方。

在这两种变体中,我的风格和模板都非常简单:

<ControlTemplate x:Key="NestedRecordTemplate">
    <TextBlock Text="test"/>
</ControlTemplate>

<Style x:Key="NestedRecordStyle" TargetType="{x:Type igDP:DataRecordPresenter}">
    <Setter Property="Template" Value="{StaticResource NestedRecordTemplate}" />
</Style>

我研究了 infragstics 论坛(有人建议使用第二个选项)和互联网,但尚未找到解决方案。

Right now i am trying to implement something like the RowDetails feature of the WPF DataGrid into the XamDataGrid. What i have tried to do (and failed until now):

1.) Replace ExpandableFieldRecordPresenterStyle

In the FieldSettings i replace the ExpandableFieldRecordPresenterStyle with my own Style
This style is sitting in the window resources and sets the Template / TemplateGridView (tried both) properties to my own DataTemplate / ControlTemplate (tried both).

This did not work, although the style was set i did not see any changes in the visual represantion.

2.) Replace the DataRecordPresenterStyle

In the FieldLayoutSettings i replace the DataRecordPresenterStyle with my own style. This does the same as the previous method and it works. However, now i have got to re-implement the original DataPresenterStyle, since i just want to add the row details control, but leave the rest unchanged. This is where i am stuck right now.

In both variants my style and template are pretty simple:

<ControlTemplate x:Key="NestedRecordTemplate">
    <TextBlock Text="test"/>
</ControlTemplate>

<Style x:Key="NestedRecordStyle" TargetType="{x:Type igDP:DataRecordPresenter}">
    <Setter Property="Template" Value="{StaticResource NestedRecordTemplate}" />
</Style>

I have researched the infragstics forums (there has been suggestions to go with the second option) and the internet and have not found a solution yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

还给你自由 2024-11-26 13:28:24

此线程中有一个示例可以用作如何完成此操作的示例: http://community.infragistics.com/forums/p/43348/238054.aspx

请注意,线程中提供的示例 Alex 使用行详细信息的绑定字段,如果没有要绑定的字段,则可以使用 UnboundField 代替。下面显示了一个示例:

<igDP:XamDataGrid x:Name="XamDataGrid1">
    <igDP:XamDataGrid.FieldLayoutSettings>
        <igDP:FieldLayoutSettings AutoGenerateFields="False"/>
    </igDP:XamDataGrid.FieldLayoutSettings>
    <igDP:XamDataGrid.FieldLayouts>
        <igDP:FieldLayout>
            <igDP:FieldLayout.Settings>
                <igDP:FieldLayoutSettings AutoArrangeCells="Never"/>
            </igDP:FieldLayout.Settings>
            <igDP:FieldLayout.Fields>
                <igDP:Field Name="EmployeeID" Row="0" Column="0"/>
                <igDP:Field Name="Name" Row="0" Column="1"/>
                <igDP:Field Name="OnSite" Row="0" Column="2"/>
                <igDP:Field Name="DateOfHire" Row="0" Column="3"/>
                <igDP:Field Name="Department" Row="0" Column="4"/>
                <igDP:Field Name="Site" Row="0" Column="5"/>
                <igDP:UnboundField Name="RowDetails" Row="1" Column="0" ColumnSpan="6">
                    <igDP:UnboundField.Settings>
                        <igDP:FieldSettings>
                            <igDP:FieldSettings.LabelPresenterStyle>
                                <Style TargetType="{x:Type igDP:LabelPresenter}">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </Style>
                            </igDP:FieldSettings.LabelPresenterStyle>
                            <igDP:FieldSettings.CellValuePresenterStyle>
                                <Style TargetType="{x:Type igDP:CellValuePresenter}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="Row Details for "/>
                                                    <TextBlock Text="{Binding DataItem.Name}"/>
                                                </StackPanel>
                                                <ControlTemplate.Triggers>
                                                    <DataTrigger Binding="{Binding IsSelected}" Value="False">
                                                        <Setter Property="Visibility" Value="Collapsed" />
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                                        <Setter Property="Visibility" Value="Visible" />
                                                    </DataTrigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </igDP:FieldSettings.CellValuePresenterStyle>
                        </igDP:FieldSettings>
                    </igDP:UnboundField.Settings>
                </igDP:UnboundField>
            </igDP:FieldLayout.Fields>
        </igDP:FieldLayout>
    </igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>

There is an example in this thread that could be used as an example on how to accomplish this: http://community.infragistics.com/forums/p/43348/238054.aspx

Note that the sample Alex provided in the thread uses a bound field for the row details and if you don't have a field to bind to, you can use an UnboundField instead. The following shows an example of what this might look like:

<igDP:XamDataGrid x:Name="XamDataGrid1">
    <igDP:XamDataGrid.FieldLayoutSettings>
        <igDP:FieldLayoutSettings AutoGenerateFields="False"/>
    </igDP:XamDataGrid.FieldLayoutSettings>
    <igDP:XamDataGrid.FieldLayouts>
        <igDP:FieldLayout>
            <igDP:FieldLayout.Settings>
                <igDP:FieldLayoutSettings AutoArrangeCells="Never"/>
            </igDP:FieldLayout.Settings>
            <igDP:FieldLayout.Fields>
                <igDP:Field Name="EmployeeID" Row="0" Column="0"/>
                <igDP:Field Name="Name" Row="0" Column="1"/>
                <igDP:Field Name="OnSite" Row="0" Column="2"/>
                <igDP:Field Name="DateOfHire" Row="0" Column="3"/>
                <igDP:Field Name="Department" Row="0" Column="4"/>
                <igDP:Field Name="Site" Row="0" Column="5"/>
                <igDP:UnboundField Name="RowDetails" Row="1" Column="0" ColumnSpan="6">
                    <igDP:UnboundField.Settings>
                        <igDP:FieldSettings>
                            <igDP:FieldSettings.LabelPresenterStyle>
                                <Style TargetType="{x:Type igDP:LabelPresenter}">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </Style>
                            </igDP:FieldSettings.LabelPresenterStyle>
                            <igDP:FieldSettings.CellValuePresenterStyle>
                                <Style TargetType="{x:Type igDP:CellValuePresenter}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="Row Details for "/>
                                                    <TextBlock Text="{Binding DataItem.Name}"/>
                                                </StackPanel>
                                                <ControlTemplate.Triggers>
                                                    <DataTrigger Binding="{Binding IsSelected}" Value="False">
                                                        <Setter Property="Visibility" Value="Collapsed" />
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                                        <Setter Property="Visibility" Value="Visible" />
                                                    </DataTrigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </igDP:FieldSettings.CellValuePresenterStyle>
                        </igDP:FieldSettings>
                    </igDP:UnboundField.Settings>
                </igDP:UnboundField>
            </igDP:FieldLayout.Fields>
        </igDP:FieldLayout>
    </igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文