如何使 WPF Toolkit 的 DataGrid 的模板列可排序?

发布于 2024-07-30 02:45:20 字数 818 浏览 1 评论 0原文

我的应用程序使用 WPF 工具包的 DataGrid。 标准列标题是可单击的(当我用鼠标移过它们时,也会出现一些效果),但模板列的标题没有这种行为。 当我单击标题时,不会触发排序事件,也没有视觉效果。

<Controls:DataGrid Sorting="DataGrid_Sorting">
    <Controls:DataGrid.Columns>
        <Controls:DataGridTextColumn Header="Hello" />
        <Controls:DataGridTemplateColumn Header="World">
            <Controls:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Button Content="Test" />
                </DataTemplate>
            </Controls:DataGridTemplateColumn.CellTemplate>
        </Controls:DataGridTemplateColumn>
    </Controls:DataGrid.Columns>
</Controls:DataGrid>

如何实现排序(或者我需要向 DataGrid 提供哪些信息)?

最好的问候, 奥利弗·哈纳皮

My application uses the DataGrid of the WPF Toolkit. Standard column headers are clickable (when I move over them with the mouse, also some effect appears), but the headers of template columns don't have this behaviour. The sorting event is not fired when I'm clicking on the header and there is also no visual effect.

<Controls:DataGrid Sorting="DataGrid_Sorting">
    <Controls:DataGrid.Columns>
        <Controls:DataGridTextColumn Header="Hello" />
        <Controls:DataGridTemplateColumn Header="World">
            <Controls:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Button Content="Test" />
                </DataTemplate>
            </Controls:DataGridTemplateColumn.CellTemplate>
        </Controls:DataGridTemplateColumn>
    </Controls:DataGrid.Columns>
</Controls:DataGrid>

How can I achieve sorting (or what information do I need to provide the DataGrid with)?

Best Regards, Oliver Hanappi

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

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

发布评论

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

评论(1

猥琐帝 2024-08-06 02:45:20

我在 CodePlex 上找到了解决方案: http://wpf.codeplex.com/ Thread/View.aspx?ThreadId=63961

致以诚挚的问候
奥利弗·哈纳皮

I have found the solution on CodePlex: http://wpf.codeplex.com/Thread/View.aspx?ThreadId=63961

Best Regards
Oliver Hanappi

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文