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:
<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>
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:
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.
P.S. I use December CTP
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.
- Proposed as answer by LeeCampbell Tuesday, January 13, 2009 11:03 PM