簡體   English   中英

如何在UWP上自定義xamarin表單應用程序的MasterDetailPage?

[英]How to Customize MasterDetailPage Of a xamarin forms app on UWP?

我正在使用xamaring表單構建應用程序,但是無法在UWP中更改母版頁眉,它在android上工作正常,但在uwp上工作正常。

這是屏幕截圖:

在此處輸入圖片說明

我要做的是更改“菜單”欄的顏色。

這是XAML代碼:

   <MasterDetailPage.Master>
        <ContentPage Title="Menu" BackgroundColor="Red">

            <StackLayout Orientation="Vertical">
                <StackLayout BackgroundColor="#e74c3c" HeightRequest="60">
                    <Label Text="SomeText"
                       FontSize="20"
                       VerticalOptions="CenterAndExpand"
                       TextColor="White"
                       HorizontalOptions="Center" />

                </StackLayout>


                <ListView x:Name="NavigationListView"
                  RowHeight="60"
                  SeparatorVisibility="None"
                  BackgroundColor="#e8e8e8"
                  ItemSelected="NavigationListView_ItemSelected">

                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout VerticalOptions="FillAndExpand"
                                     Orientation="Horizontal"
                                     Padding="20,10,0,10"
                                     Spacing="20">

                                    <Image Source="{Binding Icon}"
                                   WidthRequest="40"
                                   HeightRequest="40"
                                   VerticalOptions="Center"/>

                                    <Label Text="{Binding Title}"
                                   FontSize="Medium"
                                   VerticalOptions="Center"
                                   TextColor="Black"/>

                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackLayout>
        </ContentPage>
</MasterDetailPage.Master>

<MasterDetailPage.Detail>
    <Views:MainPage />
</MasterDetailPage.Detail>

實際上,您提到的“菜單”欄的顏色是BarBackgroundColor 因此,您可以為NavigationPage實例設置BarBackgroundColor

<MasterDetailPage.Detail>
  <NavigationPage BarBackgroundColor="PowderBlue">
    <x:Arguments>
      <pages:MasterDetailPageHomeDetail />
    </x:Arguments>
  </NavigationPage>
</MasterDetailPage.Detail>

在此處輸入圖片說明

為了使我能夠正常工作,出於某種原因,我不得不在隱藏的代碼中進行設置:

if (Device.RuntimePlatform == Device.UWP) {
    BarBackgroundColor = Colour.LighterGray;
    BarTextColor = Colour.DarkGray;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM