简体   繁体   中英

WPF Treeview Highlight selected item programmatically

When i rebuild a WPF treeview i want to set the selected item like before the rebuild. Therefore I set the property IsSelected to true and call the method focus() for the treeviewitem. 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

For more informations access this link :

link to containerfromitem usage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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