none
Multi-column TreeView. Bug with TreeViewItem layout.

    Question

  • Hello,

    I found problem with TreeViewItem layout. It can not be stretched to the whole TreeView width. Sometimes, when I use some combination of properties, the TreeViewItem behavior seems to be strange.

    I try to implement multi-column TreeView (similar to one shown on this picture: http://www.lischke-online.de/images/SmartInspect.png). TreeView should have 3 resizable columns.

    Here is the sample implementation:

    <TreeView Width="600">
    <TreeViewItem>
      <TreeViewItem.Header>
        <DockPanel LastChildFill="True">
          <TextBlock DockPanel.Dock="Right" Width="120" VerticalAlignment="center">Column 3</TextBlock>
          <TextBlock DockPanel.Dock="Right" Width="100" VerticalAlignment="center">Column 2</TextBlock>
          <Image DockPanel.Dock="Left" Source="doc.png"/>
          <TextBlock VerticalAlignment="center">Column 1</TextBlock>
        </DockPanel>
      </TreeViewItem.Header>
    </TreeViewItem>
    </TreeView>

    All columns, except "Column 1" should be stretched to the available width. But it doesn't happen. Let's change the TreeViewItem color to see what the problem is:

    <TreeViewItem Background="Yellow">

    The TreeViewItem is not stretched to whole width of the TreeView. If I try to change HorizontalAlignment, HorizontalContentAlignment and Width properties, it doesn't help. When I set fixed width for the TreeViewItem, it is aligned to the center of TreeView, but its width remains the same!

    <TreeViewItem HorizontalAlignment="Stretch" Width="400" Background="Yellow">

    Is there any way to resize the TreeViewItem to the width of the TreeView?

    Also I want to implement dotted horizontal divider lines between TreeViewItems, similar to this one: http://www.lischke-online.de/images/PCM.gif, or fill some items by solid color similar to this one: http://www.lischke-online.de/images/xStarter.jpg
    How can I do this if I can't utilize all space of the tree (is there any way to paint in the space where plus button is located?)
    May be it is possible to use layers in TreeView(Item) like in Grid? Is there any way to paint the plus button myself?

    I had an idea to use grid, but in this case I will need to implement expand/collapse logic.

    Do you plan to make the TreeView control with is not worse than VirtualTreeView (see: http://www.lischke-online.de/VirtualTreeview/). I mean the capabilities, not the architecture.

    Regards,
    Sergey.

    P.S. I use December CTP

    Thursday, January 05, 2006 9:32 PM

Answers

  • Based on the initial look, this appears to be a bug; one has been filed and reviewed by the owning team as soon as possible.
    Monday, February 20, 2006 8:11 PM
  • I think you can try to use GridViewRowPresenter and GridViewHeaderRowPresenter to implement TreeListView. It's much easier.

     

     

    Tuesday, February 21, 2006 3:03 AM

All replies

  • We're looking into this right now.  When we have more info, I'll post back.
    Friday, February 10, 2006 4:33 AM
  • Based on the initial look, this appears to be a bug; one has been filed and reviewed by the owning team as soon as possible.
    Monday, February 20, 2006 8:11 PM
  • I think you can try to use GridViewRowPresenter and GridViewHeaderRowPresenter to implement TreeListView. It's much easier.

     

     

    Tuesday, February 21, 2006 3:03 AM
  • Shi Bai, is any idea how can I realize expand/collapse logic using GridView? I need for a pretty decision, especially for large trees, but can't invent it :(

    Henry Hahn, it seems bug is still there. I use September CTP now.


     

     

    Monday, November 06, 2006 11:11 AM
  • The default content template for the Aero and Luna themes is poorly implemented (IMHO) and prevents you from doing what you are looking to do (with out some nasty hacks).

    Luckly the cause of the problem and the solution can be found here.
    http://leecampbell.blogspot.com/2009/01/horizontal-stretch-on-treeviewitems.html
    • Proposed as answer by LeeCampbell Tuesday, January 13, 2009 11:03 PM
    Tuesday, January 13, 2009 11:03 PM