microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.29k stars 675 forks source link

Proposal: TabItem and TabGroup controls #5223

Open ghost opened 3 years ago

ghost commented 3 years ago

Proposal: TabItem and TabGroup controls

Summary

I'm proposing new TabItem and TabGroup controls. They would basically be a lightweight, decoupled version of TabViewItem and TabStrip.

Rationale

Scope

Capability Priority
Adds a TabItem and TabGroup controls Must
TabItem supports reordering Should
TabGroup supports multiple rows Should
TabView gets updated to support new controls Should
TabGroup supports different orientations Could
TabItem supports different styles Could
TabItem supports closing by default Won't

Important Notes

TabItem

Ideally TabViewItem would be renamed into TabItem, because it's a more generic name. Alternatively TabViewItem could be wrapped around a TabItem, so that existing apps still work.

TabGroup

TabGroup would basically be a decoupled version of the TabView.TabStrip.


For v1, the controls would only support the minimal style.

The intention is to have them also used in TabView. The controls would have limited functionality by default, but TabView would retemplate them to add needed features (such as closing). Eventually, even NavigationView could use them.

For v2, the other styles and display modes can be added.

TabGroup should be able to completely replace the TabControl from WPF and Pivot.


This approach would allow TabView to get some functionality of NavigationView very easily:

Example usage

Creating a simple group: image

<TabGroup>
  <TabItem Header="Date and Time" />
  <TabItem Header="Additional Clocks" />
  <TabItem Header="Internet Time" />
</TabGroup>

If TabView would implement support for handling groups: image

<TabView Orientation="Left">
  <TabView.TabGroup>
    <TabGroup Header="Group 1" Color="Red">
      <TabItem Header="Tab1" />
      <TabItem Header="Tab2" />
    </TabGroup>
    <TabItem Header="Tab 3" />
  </TabView.TabGroup>
</TabView>

Open Questions

Are there other features missing from TabControl or from Pivot?

robloo commented 3 years ago

TabGroup is a very interesting, more powerful generalization of these 'tabbing' concepts. You also may have solved some concerns with naming.

You don't explicitly state, but is your intention for this TabGroup proposal to supersede TabControl? The assumption is yes, but if you confirm I'll modify #4555 pointing directly here.

Edit: Also the control needs to support collapsed TabItems correctly like in WPF. In Pivot, for example, this was never supported correctly and leads to issues. This is the only thing missing from WPF I can think of at the moment.

ghost commented 3 years ago

@robloo yes, it was meant to have full parity with TabControl and be a direct replacement. I'll update this proposal to make things more clear.

By collapsed you mean hiding tabs entirely? It should already work normally with TabViewItem, which TabItem would be based on.

robloo commented 3 years ago

yes, it was meant to have full parity with TabControl

Thanks for confirming, I just wanted to be absolutely clear.

By collapsed you mean hiding tabs entirely? It should already work normally with TabViewItem, which TabItem would be based on.

Yes, as in you can bind visibility and dynamically show/hide tabs entirely. I know it seems obvious but Pivot doesn't support this (#2952) so I want to make it absolutely clear as a spec requirement.