Reputation: 20179
I have a WPF application that includes a TreeView
. The user adds content to the tree using right click and context menu.
This creates a new TreeViewItem
that is added to the tree's ItemCollection
.
The problem is that sometimes the new items are not shown, although they were added. If you minimize/maximize the window they suddenly appear.
I tried to call TreeView.UpdateLayout()
after the addition of the new item, but the result is the same.
Any suggestions?
Upvotes: 1
Views: 1047
Reputation: 23935
dont add to the trees item collection. bind the treeview to an observable collection. keep the model and the view seperate. the treeview will reflect changes to the model. you should never have to call treeview.updateLayout. add your items to a collection. (your model) which is bound to the treeview. its a lot less work
Upvotes: 2
Reputation: 6240
I am not shure about this but try calling Refresh or call on the node witch is parent to the new node ExpandAll. Hope this works for you Best Regards, iordan
Upvotes: 0