Search Results

Search found 1 results on 1 pages for 'sperling'.

Page 1/1 | 1 

  • How to obtain the panel within a treeview (WPF)

    - by sperling
    How can one obtain the panel that is used within a TreeView? I've read that by default TreeView uses a VirtualizingStackPanel for this. When I look at a TreeView template, all I see is <ItemsPresenter />, which seems to hide the details of what panel is used. Possible solutions: 1) On the treeview instance ("tv"), from code, do this: tv.ItemsPanel. The problem is, this does not return a panel, but an ItemsPanelTemplate ("gets or sets the template that defines the panel that controls the layout of the items"). 2) Make a TreeView template that explicitly replaces <ItemsPresenter /> with your own ItemsControl.ItemsPanel. I am providing a special template anyways, so this is fine in my scenario. Then give a part name to the panel that you place within that template, and from code you can obtain that part (i.e. the panel). The problem with this? see below. (I am using a control named VirtualTreeView which is derived from TreeView, as is seen below): , use following: -- [sorry folks about poor formatting here, this is my first post, I tried 4 spaces for code... doesn't seem to work?] [I stripped out all clutter here for visibility...] The problem with this is: this immediately overrides any TreeView layout mechanism. Actually, you just get a blank screen, even when you have TreeViewItems filling the tree. Well, the reason I want to get a hold of the panel is to take some part in the MeaureOverride, but without going into all of that, I certainly do not want to rewrite the book of how to layout a treeview. I.e., doing this the step #2 way seems to invalidate the point of even using a TreeView in the first place. Sorry if there is some confusion here, thanks for any help you can offer.

    Read the article

1