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.