I'm trying to create a custom expand / collapse indicator for my tree items but there is one situation where it is not working: when the item has no children the indicator is wrong. I'm using the technique suggested in this forum post to fill my tree on demand.
I have tried two different approaches but neither one gives an accurate result.
1. Binding to IsExpanded:
I have created a value converter:
and I'm using a Label as the custom tree indicator:
This gives the best result, but when the item has no children the ExpandIcon is shown.
2. Binding to TreeViewDataItem:
I have altered the value converter to try and detect when the item has children:
group.HaveChildren is true only after getting the group's children, if it's false we don't yet have the group's children in memory.
The Label has been changed to:
With this second version, all the items always show the CollapseIcon.