在哪里可以找到 TreeListViews ColumnHeaderClick 事件?

发布于 2024-10-25 17:33:10 字数 494 浏览 1 评论 0原文

我正在开发一个工具,它以分层方式显示数据库中的数据。由于每个项目都有附加数据,因此我使用 TreeListView 控件在附加列中显示它们。列数由用户输入确定。

我使用的自定义控件是 Ricciolos TreeListView: http://windowsclient.net /blogs/ricciolocristian/archive/2008/03/22/a-complete-wpf-treelistview-control.aspx

我现在的问题是,我需要捕获 ColumnHeaderClick 事件来应用排序逻辑。我已经面试过谷歌阿姨了,但是没有结果。 也许这里有人知道在哪里可以找到这样的事件以及如何确定哪个列标题已被单击。

谢谢

I'm developing a tool which shows data from a database in a hierarchical manner. As there are additional data for each item I'm using a TreeListView control to display them in additional columns. The number of columns is determined by user input.

The custom control that I'm using is Ricciolos TreeListView:
http://windowsclient.net/blogs/ricciolocristian/archive/2008/03/22/a-complete-wpf-treelistview-control.aspx

My problem now is, that I need to catch the ColumnHeaderClick event to apply a sorting logic. I already interviewed auntie Google, but no results.
Maybe somene here knows where to find such an event and how to determine which column header has been clicked.

Thanks

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

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

发布评论

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

评论(1

久而酒知 2024-11-01 17:33:10

您需要为 GridViewColumnHeader.Click 事件添加处理程序。此帖子介绍了如何为 ListView 执行此操作,它使用相同的底层控件。此代码改编自该链接:

myTreeListView.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(this.OnGridViewColumnHeaderClicked));

private void OnGridViewColumnHeaderClicked(object sender, RoutedEventArgs e) {
    MessageBox.Show("testing");
}

或者,您可以通过 XAML 附加处理程序,如下所示:

<my:TreeListView GridViewColumnHeader.Click="OnGridViewColumnHeaderClicked" />

e.OriginalSource 将包含 GridViewColumnHeader,e.Source/sender 将是 TreeListView。

You would need to add a handler for the GridViewColumnHeader.Click event. This post describes how to do it for the ListView, which uses the same underlying controls. This code was adapted from that link:

myTreeListView.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(this.OnGridViewColumnHeaderClicked));

private void OnGridViewColumnHeaderClicked(object sender, RoutedEventArgs e) {
    MessageBox.Show("testing");
}

Alternatively, you can attach a handler via XAML like so:

<my:TreeListView GridViewColumnHeader.Click="OnGridViewColumnHeaderClicked" />

The e.OriginalSource will include the GridViewColumnHeader, and e.Source/sender would be the TreeListView.

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