Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TabView suddenly missing from UWP

Tags:

tabs

uwp

Was trying to implement a TabView in my UWP project yesterday but it doesn't show up in the ToolBox and if I add it via code it says

TabView is not supported in a Windows Universal Project.

Though the documentation on the website is fairly recent and clear: https://learn.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/tab-view

I put the UWP requirement on latest Windows 10 build. Running Visual Studio 2019 Enterprise.

More information or help is appreciated.

like image 748
Jesse Avatar asked Jun 05 '26 17:06

Jesse


2 Answers

From this document of TabView, you can see that the TabView is under the Microsoft.UI.Xaml.Controls namespace and applies to WinUI. So you need to install Microsoft.UI.Xaml nuget package and add the Windows UI (WinUI) Theme Resources to your App.xaml resources. Then add the namespace in xaml to use it.

App.xaml:

<Application ...>
    <Application.Resources>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
    </Application.Resources>
</Application>

MainPage.xaml:

<Page
    ......
    xmlns:control="using:Microsoft.UI.Xaml.Controls">

    <Grid>
        <control:TabView HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            ......
        </control:TabView>
    </Grid>
</Page>
like image 176
Faywang - MSFT Avatar answered Jun 08 '26 06:06

Faywang - MSFT


It's confusing, but there are (at least) two TabViews you can use in UWP applications:

https://learn.microsoft.com/en-us/uwp/api/microsoft.ui.xaml.controls.tabview

xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
...
<muxc:TabView>

and from the windows community toolkit

https://learn.microsoft.com/en-us/dotnet/api/microsoft.toolkit.uwp.ui.controls.tabview

xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
...
<controls:TabView >

They look different. The toolkit version is flatter, and have slightly different naming and hierarchy for some properties.

If you're not careful about which documentation your reading from, you can end up with code that is an invalid mishmash of the properties hierarchy from both classes.

like image 32
compound eye Avatar answered Jun 08 '26 08:06

compound eye