AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.22k stars 2.18k forks source link

Add TabWidthMode Property to TabStrip/TabControl #8243

Open robloo opened 2 years ago

robloo commented 2 years ago

Is your feature request related to a problem? Please describe.

In some scenarios its common to automatically size tab item header widths to (1) fit available width and (2) keep uniform width among each tab item.

In WPF this was never supported directly; however, UWP TabView has a property:

TabView.TabWidthMode TabViewWidthMode

image

This should be added to TabStrip and TabControl

Describe the solution you'd like

Included above

Describe alternatives you've considered

As mentioned below it's possible to swap out the ItemPanel. However, that is a bit more complicated and certain panels don't always behave as wanted.

Additional context

N/A

maxkatz6 commented 2 years ago

I see possible implementation using custom tabs Panel type that arranges children in a way depending on this property.

(1) fit available width and (2) keep uniform width among each tab item.

You can set TabControl.ItemPanel to UniformGrid with specific number of columns. Which isn't the same but can solve it mostly. Especially with converter from items count to a rows count, when you want to limit columns as well. Together with other types of panels, including custom ones, TabWidthMode would be limiting.

Saying that, I personally don't see problems of having both TabWidthMode for simple well-known scenarios and ItemPanel for more advanced.

robloo commented 2 years ago

You can set TabControl.ItemPanel to UniformGrid with specific number of columns.

Yes, this is what I'm doing now. I just realized TabView had this built in and it's pretty nice to have available.

Saying that, I personally don't see problems of having both TabWidthMode for simple well-known scenarios and ItemPanel for more advanced.

Yes, I agree ItemPanel should still be supported.