I am new to WPF and I would like TreeView to show expand/collapse icon (the triangle beside node) at all times, regardless whether node has items in it.
To show it at all times, I add a dummy item for nodes that have no items ending up with something like below (for now, I would like to do this in code-behind):
+ Node 1
- Node 2
- Dummy Item
+ Node 3
Further requirement is to delete Dummy Item once the node having it is expanded.
To do that, I remove the item in OnExpand:
public void OnExpand(object sender, EventArgs e)
{
...
foreach (var item in tvItems){
if (item is dummy){
tvItems.Children.Remove(item);
}
}
...
}
The problem with this is that once node is expanded, I see empty line
+ Node 1
- Node 2
<-- How to remove this line?
+ Node 3
How do I remove this line so that list shows like:
+ Node 1
Node 2 // there is no empty line btw Node 2 and Node 3
+ Node 3