views:

20

answers:

0

I have a WPF TreeView that has ScrollViewerVerticalScrollBarVisibility set to Auto. This treeview is in a Border, which is in a Grid.

When I start my app, it populates the treeview and the length of the treeview is too long for the panel. So I'd expect a scrollbar. And as expected about 75% of the time I get one. But about 1/4 of the time time there is no scrollbar (and the repro is exactly the same, just start the app up, and sometimes I get it, and sometimes I don't).

I can get a scrollbar to appear by expanding an item in the treeview (if I then immediately collpase the item, it returns the treeview to its original size, but the scrollbar stays on the screen).

I have tried various things like InvalidateLayout on the TreeView and toggling the ScrollViewer visibility from Visible to Auto. But none of these seem to work thus far. And in the actual UI, if I change the size of the Grid it doesn't matter. Scrollbars won't appear until I expand one of the items (and then changing the size of the grid causes the size of the scrollbar thumb to change correctly).

Any ideas? Has anyone else seen this?

BTW, this is .NET 4.0 on Windows 7 (64bit version of the OS, although the app is running in 32bit mode).