簡體   English   中英

顯示分配給 Xamarin.Forms Shell 的 ContentPage 導航欄的默認后退按鈕

[英]Displaying the default back button of the navigation bar of a ContentPage assigned to the Xamarin.Forms Shell

I have a ContentPage which is assigned to the Xamarin.Forms.Shell class as a ShellContent and require the back button to be displayed in the navigation bar of the ContentPage .

關注的ContentPage的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="UI_test.TestPage">

    <Shell.NavBarIsVisible>True</Shell.NavBarIsVisible>
    <Shell.BackButtonBehavior>
        <BackButtonBehavior IsEnabled="True" />
    </Shell.BackButtonBehavior>
    
    <Shell.FlyoutBehavior>Disabled</Shell.FlyoutBehavior>

    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to Xamarin.Forms!"
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

我發現為<BackButtonBehavior>標簽的TextOverrideIconOverride屬性分配自定義值將顯示后退按鈕,但我正在尋找一種方法來顯示平台的默認后退按鈕(而不是自定義的),如上所述ContentPage不會在其導航欄中顯示為后退按鈕,如下面的屏幕截圖所示。

關注的 ContentPage 的屏幕截圖

提前致謝。

您的項目似乎只包含一頁,如果沒有進行導航,它將不會出現,這是有道理的。 If you do a Shell.GotoAsync(..) or Shell.Navigation.PushAsync(..) to navigate to another page it will then appears (the default native back button) allowing to go back to the previous page in the navigation stack.

暫無
暫無

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

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