【问题标题】:Xamarin Forms NavigationPage BarBackgroundcolor doesn't see the same on every pageXamarin Forms NavigationPage BarBackgroundcolor 在每个页面上都不同
【发布时间】:2016-08-03 16:10:38
【问题描述】:

我是 Xamarin Forms 的新手。 MasterDetailPage 中的 NavigationPage BarBackgroundcolor 有问题。它在每一页上都没有看到相同的内容。那是 Xamarin Forms Portable 项目和我的代码;

<?xml version="1.0" encoding="UTF-8"?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" 
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
                  xmlns:local="clr-namespace:MasterDetailPageNavigation;assembly=MasterDetailPageNavigation"
                  x:Class="MasterDetailPageNavigation.MainPage">
  <MasterDetailPage.Master>
    <local:MasterPage x:Name="masterPage" BackgroundColor="#fe5722" />
  </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
        <NavigationPage BarBackgroundColor="#fe5722" BarTextColor="White">
            <x:Arguments>
                <local:HomePage />
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>
</MasterDetailPage>

我猜它可能在应用页面上。但是怎么做?我能做些什么来解决这个问题?

【问题讨论】:

  • 您的MasterDetailPageNavigation 中有什么内容?

标签: xamarin xamarin.ios xamarin.android xamarin.forms


【解决方案1】:

我修复了我的代码,该问题已解决。我在 MainPage.xaml.cs 上设置了 Barbackgroundcolor

var item = e.SelectedItem as MasterPageItem;
        if (item != null) {
            Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType)) 
            { BarTextColor=Color.White,BarBackgroundColor=Color.FromHex("fe5722") };
            masterPage.ListView.SelectedItem = null;
            IsPresented = false;
        }

【讨论】:

    【解决方案2】:

    您必须将母版页的 BackgroundColor 设置为显示在导航栏中。此外,最好在 android 的主题中指定它,以便为您提供材质样式。

    论坛里已经有很多讨论了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多