2016-08-03 53 views
1

我是Xamarin Forms的新手。我在MasterDetailPage中遇到了NavigationPage BarBackgroundcolor的问题。它在每个页面上都看不到。这是Xamarin Forms Portable项目和我的代码;Xamarin Forms NavigationPage BarBackgroundcolor在每个页面上看不到相同的内容

<?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> 

我想这可能是在App页面上。但是如何?我能做些什么来解决这个问题?

+0

什么在你的'MasterDetailPageNavigation'? –

回答

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; 
     } 
相关问题