Avalonia.ExtendedToolkit icon indicating copy to clipboard operation
Avalonia.ExtendedToolkit copied to clipboard

TreeViewItem with no items shouldn't show the toggle button

Open MikePelton opened this issue 1 year ago • 0 comments

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.

MikePelton avatar Jan 06 '23 09:01 MikePelton