如何更改带有 ItemSource 绑定的 WPF Listview SelectedItem 字体颜色?

发布于 2024-11-26 11:03:51 字数 190 浏览 1 评论 0原文

我有一个包含列表视图的 WPF 窗口,该列表视图的 itemsource 设置为对象集合。当我访问 SelectedItem 或 SelectedItems[] 或 Items[] 时,我会取回绑定到该项目的对象,而不是 ListViewItem 项目本身。我不知道如何选择一行并更改其颜色,因为我无法访问该项目本身,例如 winform listviewitem。

I have WPF window containing a listview that has it's itemsource set to a collection of objects. When I access SelectedItem or SelectedItems[] or Items[], I get the my object back that's bound to that item, not the ListViewItem item itself. I have no idea how to select a row and change it's color since I can't access the item itself, like a winform listviewitem.

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

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

发布评论

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

评论(1

明月松间行 2024-12-03 11:03:51

ListView 派生自 ItemsControl,它公开 ItemContainerGenerator 属性。该对象允许您将绑定实体映射到其 ItemContainer(您正在查找的项目)并返回。

ListView derives from ItemsControl which exposes the ItemContainerGenerator property. This object allows you to map a bound entity to its ItemContainer (the item your are looking for) and back.

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