Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Answer by Liyun Zhang - MSFT for Use a custom control Navigation Bar in Maui Shell

$
0
0

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:

  1. Grid.Children.Add has been to changed as Grid.Add. Such as this.Add(boxView, 0, 1);.
  2. 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.


Viewing all articles
Browse latest Browse all 445

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>