Hi
In my project the Main page is a tabbedpage and when we switch from the main page to another page which is also a tabbed page we are seeing System.NotSupportedException: 'Unable to find the default constructor on type Microsoft.Maui.Controls.Platform.FragmentContainer. Please provide the missing constructor.'
The tabbedpages internally have one more tabbed page to have tabs.
I am not able to find the place where this exception occurred and not able to fix it.
please let us know how to proceed and fix this.
Thanks
I am seeing the issue in Android and MAUI version is 8.
APP.XAML.CS
public App()
{
InitializeComponent();
}
public App(IServiceProvider services ,DatabaseContext context)
{
InitializeComponent();
Services = services;
CustomContentPageHandler.RegisterHandlers();
MainPage = new NavigationPage(new MainTabs());
DbContext = context;
Routing.RegisterRoute(nameof(AboutPage), typeof(AboutPage));
}
Tab4
<?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"
xmlns:views="clr-namespace:MediaShare.View"
xmlns:locale="clr-namespace:MediaShare.Resources"
x:Class="MediaShare.View.Tab4"
Title="Tab4"
SelectedTabColor="{StaticResource StatusBarColor}"
UnselectedTabColor="{StaticResource Gray_text}"
>
<TabbedPage.Resources>
<Style TargetType="views:MyDevices">
<Setter Property="Title" Value="Roboto"/>
</Style>
</TabbedPage.Resources>
<NavigationPage.TitleView>
<Grid ColumnDefinitions="Auto,*">
<views:CustomTitleBar x:Name="customTitleBar" Grid.Column="0"/>
<Border Grid.Column="1"
x:Name="searchBorder"
Style="{StaticResource SearchBorder}">
<SearchBar Grid.Column="1"
x:Name="searchBarGrid"
Style="{StaticResource Search}"
Text="{Binding SearchQuery, Mode=TwoWay}"
TextChanged="OnSearchTextChanged"
Placeholder="{x:Static locale:String_en.SearchDevice}"
/>
</Border>
</Grid>
</NavigationPage.TitleView>
<TabbedPage.ToolbarItems>
<ToolbarItem IconImageSource="ic_search.svg"
Priority="2"
x:Name="searchMenu"
Clicked="OnSearchClicked"
Order="Primary"/>
</TabbedPage.ToolbarItems>
<views:Test1 x:Name="Test1" Title="Test1"/>
<views:Test2 x:Name="Test2" Title="Test2" IsEnabled="False"/>
<views:Test3 x:Name="Test3" Title="Test3" IsEnabled="False" />
</TabbedPage>
Tab1
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:MediaShare.View"
xmlns:locale="clr-namespace:MediaShare.Resources"
x:Class="MediaShare.View.Tab1"
Title="Tab1">
<NavigationPage.TitleView>
<Grid ColumnDefinitions="Auto,*">
<views:CustomTitleBar x:Name="customTitleBar" Grid.Column="0" />
<Border Grid.Column="1"
x:Name="searchBorder"
Style="{StaticResource SearchBorder}">
<SearchBar Grid.Column="1"
x:Name="searchBar"
Style="{StaticResource Search}"
Text="{Binding SearchQuery, Mode=TwoWay}"
TextChanged="OnSearchTextChanged"
CancelButtonColor="Black"
Unfocused="OnSearchBarUnFocused"
Placeholder="{x:Static locale:String_en.SearchFile}"
/>
</Border>
</Grid>
</NavigationPage.TitleView>
<TabbedPage.ToolbarItems>
<ToolbarItem IconImageSource="ic_search.svg"
Priority="2"
x:Name="searchMenu"
Clicked="OnSearchClicked"
Order="Primary"/>
<ToolbarItem x:Name="infoMenu" IconImageSource="info_button.svg"
Priority="3"
Clicked="OnInfoClicked"
Order="Primary"/>
<ToolbarItem x:Name="InfoButton" Text="{x:Static locale:String_en.Info}" Order="Secondary" Priority="0" />
<ToolbarItem x:Name="SelectionButton" Text="{x:Static locale:String_en.Select_All}" Order="Secondary" Priority="1" Command="{Binding SelectAllCommand}" IsEnabled="{Binding IsSelectionEnabled}"/>
<ToolbarItem x:Name="ClearButton" Text="{x:Static locale:String_en.ClearSelection}" Order="Secondary" Priority="2" Command="{Binding DeselectAllCommand}" IsEnabled="{Binding IsAnyItemSelected}"/>
</TabbedPage.ToolbarItems>
<views:Tab1SubTabs x:Name="Tab1subtabsview" />
</TabbedPage>
Main TABS
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:MediaShare.View"
xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
android:TabbedPage.ToolbarPlacement="Bottom"
x:Class="MediaShare.View.MainTabs"
Title="MainTabs"
IconImageSource="device.svg"
BarBackground="#caeaff">
<TabbedPage.Children>
<NavigationPage x:Name="Tab1" Title="Tab1" IconImageSource="up_arrow.svg" BarBackgroundColor="#007acc" BarTextColor="White">
<x:Arguments>
<views:Tab1/>
</x:Arguments>
</NavigationPage>
<NavigationPage x:Name="Tab2" Title="Tab2" IconImageSource="down_Arrow.svg" BarBackgroundColor="#007acc" BarTextColor="White">
<x:Arguments>
<views:Tab2/>
</x:Arguments>
</NavigationPage>
<NavigationPage x:Name="Tab3" Title="Tab3" IconImageSource="history.svg" BarBackgroundColor="#007acc" BarTextColor="White" >
<x:Arguments>
<views:Tab3/>
</x:Arguments>
</NavigationPage>
<NavigationPage x:Name="Tab4" Title="Tab4" IconImageSource="device.svg" BarBackgroundColor="#007acc" BarTextColor="White">
<x:Arguments>
<views:Tab4/>
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>