在VS17中更改Xamarin.Forms MasterDetail标题中的图标和标题?

时间:2017-11-11 15:25:31

标签: c# android xamarin xamarin.forms

所以无论我做什么,我都无法在MasterDetail页面的Bar Header中设置图标或标题:

enter image description here

正如您在此处所见,显示标准@ drawable / icon.png。但我需要它与应用程序图标不同。 并且图标右侧没有标题。

无论我尝试什么,我都无法改变这两者。 (汉堡包图标虽然可以改变)

我在MasterDetailPage页面上尝试了这些:

Title = "something";
Master.Title = "something";
Detail.Title = "something";

Icon = "something.png";
Master.Icon = "something.png";
Detail.Icon = "something.png";

BackgroundImage = "something.png";
Master.BackgroundImage = "something.png";
Detail.BackgroundImage = "something.png";

主页(继承自MasterDetailPage)如下所示:

public class MainPage : MasterDetailPage
{
    public SharedNaviPages.MasterPage masterPage;

    public MainPage()
    {
        masterPage = new SharedNaviPages.MasterPage();
        Master = masterPage;

        if (App.IsUserLoggedIn)
        {
            Detail = new NavigationPage(new Views.CompanyPages.BookingPage());
        } else
        {
            Detail = new NavigationPage(new SharedNaviPages.LoginPage());
        }

        masterPage.ListView.ItemSelected += OnItemSelected;

        if (Device.RuntimePlatform == Device.UWP)
        {
            MasterBehavior = MasterBehavior.Popover;
        }
    }

我的MainPage.cs只是组织主页面和详细信息页面。 预订页面有一个.Xaml视图和一个代码隐藏文件。

BookingPage.xaml:

    <?xml version="1.0" encoding="UTF-8"?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="HoldbarVikar.Views.CompanyPages.BookingPage"
             Title="Bookinger">
    <ContentPage.Content>
    <StackLayout>
                <Label Text="Bookings data goes here" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

BookingPage.xaml.cs:

using Xamarin.Forms;

namespace HoldbarVikar.Views.CompanyPages
{
public partial class BookingPage : ContentPage
{
    public BookingPage()
    {
        InitializeComponent();

    }
}
}

0 个答案:

没有答案