C
C#5mo ago
kevin

Tabbed pages in MAUI

Hello I'm trying to create a TabbedPage in MAUI using the following code:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Project.View.DashboardView"
xmlns:local="clr-namespace:Project.View">

<local:GameView Title="Game" />

</TabbedPage>
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Project.View.DashboardView"
xmlns:local="clr-namespace:Project.View">

<local:GameView Title="Game" />

</TabbedPage>
I get 2 errors: Partial declarations of 'DashboardView' must not specify different base classes and Argument 1: cannot convert from 'Project.View.DashboardView' to 'Microsoft.Maui.Controls.Page If i change <TabbedPage> to ContentPage it works. Here's the line of code where the error occurs:
private void DashboardBtn_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new DashboardView());
}
private void DashboardBtn_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new DashboardView());
}
4 Replies
Keswiik
Keswiik5mo ago
Show what's in DashboardView.xaml.cs as well
kevin
kevin5mo ago
namespace Project.View;

public partial class DashboardView : ContentPage
{
public DashboardView()
{
InitializeComponent();
}
}
namespace Project.View;

public partial class DashboardView : ContentPage
{
public DashboardView()
{
InitializeComponent();
}
}
Keswiik
Keswiik5mo ago
probably having problems because your main page (now a TabbedPage) is still extending ContentPage
Sir Rufo
Sir Rufo5mo ago
change your code in DashboardView.xaml.csto
c#
namespace Project.View;

public partial class DashboardView // remove it : ContentPage
{
public DashboardView()
{
InitializeComponent();
}
}
c#
namespace Project.View;

public partial class DashboardView // remove it : ContentPage
{
public DashboardView()
{
InitializeComponent();
}
}
and after that change the DashboardView.xaml to TabbedPage again.
Want results from more Discord servers?
Add your server
More Posts