简体   繁体   English

WPF Treeview以编程方式突出显示所选项目

[英]WPF Treeview Highlight selected item programmatically

When i rebuild a WPF treeview i want to set the selected item like before the rebuild. 当我重建WPF树视图时,我想像重建之前一样设置选定的项目。 Therefore I set the property IsSelected to true and call the method focus() for the treeviewitem. 因此,我将属性IsSelected设置为true并为treeviewitem调用方法focus()。 But the background of the selected item is only a pale gray color. 但是所选项目的背景只有浅灰色。 How can achieve the standard blue background programmatically. 如何以编程方式达到标准的蓝色背景。 When I click the item with the mouse the item background is blue again. 当我用鼠标单击项目时,项目背景再次变为蓝色。

You should use ContainerFromItem 您应该使用ContainerFromItem

For more informations access this link : 有关更多信息,请访问此链接:

link to containerfromitem usage 链接到containerfromitem的用法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM