microsoft / microsoft-ui-xaml

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

Proposal: Add `TabDisplayMode` for `TabView` #7202

Open kingcean opened 2 years ago

kingcean commented 2 years ago

Summary

When we implement a browser with tabs, we may need to hide the tabs on full screen. So please add a property TabDisplayMode for TabView class to allow to do so. Its type is an Enum with following values.

Rationale

Important Notes

Following is the Enum definition for example mentioned above.

public enum TabDisplayMode : byte
{
    Default = 0,
    Overlay = 1,
    Hidden = 2,
}

And add the property to TabView.

[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.UI.Xaml.Markup.ContentProperty(Name="TabItems")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.XamlContract), 65536)]
public class TabView : Control
{
+    public TabDisplayMode TabDisplayMode { get; set; }
}

Following is the usage example.

<Grid>
    <Border x:Name="TopElement"
        Height="1"
        VerticalAlignment="Top"
        PointerEntered="TopElement_PointerEntered"
        PointerExited="TopElement_PointerExited"  />
    <TabView x:Name="TabViewElement" >
        <!-- Some tabs -->
    </TabView>
</Grid>
private void TopElement_PointerEntered(object sender, PointerRoutedEventArgs e)
    => TabViewElement.TabDisplayMode = TabDisplayMode.Overlay;

private void TopElement_PointerExited(object sender, PointerRoutedEventArgs e)
    => TabViewElement.TabDisplayMode = TabDisplayMode..Hidden;

Open Questions

It would be great if WinUI team could also add vertical tabs.

kingcean commented 1 year ago

Is there any plan to add such feature? Thanks!