Avalonia.ExtendedToolkit
Avalonia.ExtendedToolkit copied to clipboard
TreeViewItem with no items shouldn't show the toggle button
In Controls.TreeView.axaml lines 157-159 are commented out:
<!--<Style Selector="TreeViewItem[HasItems=false] /template/ Controls|MetroToggleButton#Expander">
<Setter Property="IsVisible" Value="false" />
</Style>-->
In the original design they switch the "expand" toggle off when the item has no sub-items, which is the expected behaviour. The good news is the Avalonia "ItemsControl" that TreeViewItem inherits from gives us an "empty" pseudoclass, so replacing those lines thus:
<Style Selector="TreeViewItem:empty /template/ Controls|MetroToggleButton#Expander">
<Setter Property="IsVisible" Value="false" />
</Style>
...restores the behaviour. I think I'd also argue that the toggle should have the active foregound colour, so line 32:
Fill="{TemplateBinding Background}"
... should actually be:
Fill="{TemplateBinding Foreground}"
...but that's based on my perceived ease of use rather than the specifics of the design language.