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.
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>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With