treeview with + and lines

essamce 581 Reputation points
2020-08-31T09:08:31.98+00:00

21420-toolspace.png

hi, how to make treeview with node symbol as + symbol (instead of triangle) which converts to - symbol when expanded, and how to add lines (dash lines) that makes it easy to follow the intendations of the tree.
thanks in advance

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,173 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 65,366 Reputation points
    2020-08-31T09:16:05.11+00:00

    You can see for example : WPF TreeView with WinForms Style Fomat

    No comments

  2. DaisyTian-1203 11,506 Reputation points
    2020-09-01T03:20:24.933+00:00

    You can use Shape.StrokeDashArray to draw dotted lines for the TreeViewItems.You can replace the HorLn and VerLn in the demo which provided by Castorix31 like below:

     <!-- Connecting dotted Lines -->  
                                <!-- Horizontal line -->  
                                <Rectangle x:Name="HorLn" Height="1" VerticalAlignment="Center" StrokeDashArray="4 4" HorizontalAlignment="Stretch" Stroke="#8888" Margin="9,0,0,0" SnapsToDevicePixels="True"/>  
                                <!-- Vertical line -->  
                                <Rectangle x:Name="VerLn" Width="1" VerticalAlignment="Stretch" StrokeDashArray="4 4" HorizontalAlignment="Center" Stroke="#8888" Grid.RowSpan="2" SnapsToDevicePixels="True"/>  
    

    Here is the whole code for you to test.

    No comments