Datagrid模板和冻结列 [英] Datagrid template and frozen columns

查看:76
本文介绍了Datagrid模板和冻结列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我想在包含文本字段的数据网格中设置页脚。我想到了类似的东西,但此刻,如果我设置FrozenColumnCount =5冻结仍然只有行,但页脚和标题不是我在做错的地方



我尝试过:



Hello
I would like make footer in datagrid consisting of text fields. I thought about something like that but at the moment when if I set FrozenColumnCount = "5" frozen remain only the rows but footer and headers not Where I'm doing mistake

What I have tried:

<ControlTemplate TargetType="{x:Type DataGrid}">
                            <Border >
                                <ScrollViewer>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition/>
                                            <RowDefinition/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <DataGridColumnHeadersPresenter Grid.Row="0"/>
                                        <ItemsPresenter Grid.Row="1"/>
                                        <WrapPanel Grid.Row="2">
                                            <TextBox Text="Tekst1"/>
                                            <TextBox Text="Tekst2"/>
                                            <TextBox Text="Tekst3"/>
                                            <TextBox Text="Tekst4"/>
                                            <TextBox Text="Tekst5"/>
                                            <TextBox Text="Tekst6"/>
                                        </WrapPanel>
                                    </Grid>
                                </ScrollViewer>
                            </Border>
                        </ControlTemplate>

推荐答案

Google搜索是您的朋友。有很多答案供您选择: wpf datagrid冻结列 [ ^ ]
Google Search is your Friend. There are plenty of answers for you to choose from: wpf datagrid frozen columns[^]


好的,所以你正在使用黑客添加一个页脚,而不是控件中固有的。



解决方案是将页脚ScrollViewer绑定到DataGrid的ScrollViewer,两者将同步移动。页脚中镜像的冻结单元格需要位于页脚的ScrollViewer之外。
Okay, so you are using a hack to add a footer, not inherent in the control.

The solution is to bind the footer ScrollViewer to the DataGrid's ScrollViewer and the two will move in sync. The frozen cells mirrored in the footer need to be outside the footer's ScrollViewer.


替代方案,更好的解决方案是抛弃标准DataGrid并使用 syncfusion [ ^ ] DataGrid [ ^ ]。他们有社区许可证,不会花费你一分钱。



你可以在他们的文档 [ ^ ]



我不参与syncfusion,也不使用他们的产品。
An alternative, and a much better solution for you is to ditch the standard DataGrid and use syncfusion[^] DataGrid[^]. They have Community Licences that won't cost you a cent.

You can read more about this in their documentation[^]

I am not affiliated with syncfusion nor do I use their products.


这篇关于Datagrid模板和冻结列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆