I have converted your xamarin forms code in the github link to the maui. And it worked in the .net maui. There are some points:
Grid.Children.Add
has been to changed asGrid.Add
. Such asthis.Add(boxView, 0, 1);
.- The
SetColumnSpan(boxView, 5)
need to declare parameter:SetColumnSpan(view: boxView, 5)
You can just copy your code into maui project and change it as the code above. And then use the TitleView in the AppShell.xaml:
<Shell.TitleView><controls:TitleView Title="Test"></controls:TitleView></Shell.TitleView>
In addition, there is blank space at the left side on the android. Adding the following code in the App class's constructor can fix it:
public App() { Microsoft.Maui.Handlers.ToolbarHandler.Mapper.AppendToMapping("CustomNavigationView", (handler, view) => {#if ANDROID handler.PlatformView.ContentInsetStartWithNavigation = 0; handler.PlatformView.SetContentInsetsAbsolute(0, 0);#endif }); InitializeComponent(); }
And for the iOS, you can refer to this pull request:[iOS] Shell/NavigationPage TitleView.