Hello I have a TreeView that I filled with a list of TreeViewItem from a collection (using the binding), I linked to a TreeView event "Expand" to expand it and display their childrens, my objective now is to get the last TreeViewItem accessed and to initialize the TreeView by the last treeViewItem consulted. I can retrieve the last TreeViewItem consulted and their childrens, but I can not expand it automatically. I use this method, but it returns always null.
TreeViewItem item =control.ItemContainerGenerator.ContainerFromItem(lastItem)as TreeViewItem; item.IsExpanded = true;
item is always null, isExpanded doses not work, and lastItem is a string(the text you see on the screen : is the treeViewItem.datacontext recovred ).