如何更改带有 ItemSource 绑定的 WPF Listview SelectedItem 字体颜色?
我有一个包含列表视图的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.