使用 Xamarin Forms 为 Android 和 iOS 创建底部导航栏



是否可以使用 Xamarin Forms 为 Android 和 iOS 创建底部导航栏,而无需使用自定义渲染器。

我听说最新的 Xamarin 窗体支持底部导航栏功能,但遗憾的是我无法找到合适的文档。

需要一些帮助/指南来实现相同的内容。

我正在分享我的应用程序代码,希望对您有所帮助。

XML 页面 :

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="iSAS.Mobile.Views.Student.SettingsPage"
         Title="Profile" 
         xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
         BarBackgroundColor="White"
         BarTextColor="#2196F3" 
         android:TabbedPage.ToolbarPlacement="Bottom"
         android:TabbedPage.BarItemColor="#66FFFFFF"
         android:TabbedPage.BarSelectedItemColor="#2196F3" >
 </TabbedPage>

客户服务页面 :

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SettingsPage : TabbedPage
{
    public SettingsPage()
    {
        InitializeComponent();
        Children.Add(new ProfilePage());
        Children.Add(new ChangePassword());
        Children[0].Icon = "profile.png";
        Children[1].Icon = "settings.png";
        CurrentPage = Children[1];
    }
    public SettingsPage(bool DefaultChangePswdPage = true)
    {
        InitializeComponent();
        Children.Add(new ProfilePage());
        Children.Add(new ChangePassword());
        Children[0].Icon = "profile.png";
        Children[1].Icon = "settings.png";
        if (DefaultChangePswdPage)
            CurrentPage = Children[1];
    }
}

最新更新