Skip to content

TreeView should expose Header/Footer properties and make use of underlying ListView #8451

@michael-hawker

Description

@michael-hawker

Describe the bug

TreeView's template uses a TreeViewList:

<ControlTemplate TargetType="local:TreeView">
<local:TreeViewList
x:Name="ListControl"
Background="{TemplateBinding Background}"
ItemTemplate="{TemplateBinding ItemTemplate}"
ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
ItemContainerStyleSelector="{TemplateBinding ItemContainerStyleSelector}"
ItemContainerTransitions="{TemplateBinding ItemContainerTransitions}"
CanDragItems="{TemplateBinding CanDragItems}"
AllowDrop="{TemplateBinding AllowDrop}"
CanReorderItems="{TemplateBinding CanReorderItems}">
</local:TreeViewList>

Which is just a ListView:

unsealed runtimeclass TreeViewList : Windows.UI.Xaml.Controls.ListView
{
TreeViewList();
}

ListView has a Header and Footer property available like most XAML controls; however, TreeView does not.

TreeView should get Header and Footer properties and they should just be template bound to the underlying TreeViewList in the default template.

This would make moving from ListView/ItemsControl to TreeView easier as they would all support the Header/Footer property like most XAML controls. Came about from my exploration of applying my DataTable experiment to a TreeView, needed to do this manually in a sub-class, but it should be just built-in to the WinUI 2/3 versions of this control instead. Should be a straight-forward add-on. See: CommunityToolkit/Labs-Windows#415

Steps to reproduce the bug

  1. Create a TreeView in XAML
  2. Try and set a Header property...
  3. None exists...

Expected behavior

Should have standard Header/Footer properties like other XAML controls, makes it easier to have consistent UI and styling when creating various layouts and/or form-style UI.

Screenshots

No response

NuGet package version

WinUI 2 - Microsoft.UI.Xaml 2.8.2

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeature proposalNew feature proposalteam-ControlsIssue for the Controls teamwct

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions