Irritating blank space between Title Bar and Tabs in Xamarin.Forms UWP project

余生长醉 提交于 2019-12-06 02:43:38

You need to create a custom TabbedPage and then a UWP renderer for it.

First you create a CustomTabbedPage in the PCL:

public class CustomTabbedPage : TabbedPage { }

In your XAML, use this CustomTabbedPage instead of the TabbedPage. All behavior and UI will stay the same on all platforms.

Now you create a renderer in the UWP project:

[assembly: ExportRenderer(typeof(CustomTabbedPage), typeof(CustomTabbedPageRenderer))]

namespace App.UWP
{

    public class CustomTabbedPageRenderer : TabbedPageRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            Control.TitleVisibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
    }
}

We use the FormsPivot.TitleVisibility to hide the Title area.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!