views:

196

answers:

2

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?

A: 

Hi, 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

IordanTanev
A: 

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

Aran Mulholland