在我的 Xamarin Forms 5 應用程式中,我的頁腳中有一個設定圖示,AppShell單擊時,我打開了一個TabbedPage. 這部分作業正常,但是當頁面打開時,我看到頂部的后退按鈕。我希望它TabbedPage的外觀和行為與FlyoutItems 部分中的任何其他頁面一樣。
這是我要創建的效果:

我可以在我的以下內容中創建它ShellFooter:
<Grid xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Ingrid.Connect.Views.FlyoutFooter"
RowDefinitions="120"
ColumnDefinitions="150, 150">
<Image
Grid.Row="0"
Grid.Column="0"
HorizontalOptions="StartAndExpand"
Margin="50,0,0,0">
<Image.Source>
<FontImageSource
FontFamily="MISHRP"
Glyph="{StaticResource SettingsIcon}"
Color="White"/>
</Image.Source>
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="Settings_Tapped" />
</Image.GestureRecognizers>
</Image>
<Image
Grid.Row="0"
Grid.Column="1"
HorizontalOptions="EndAndExpand"
Margin="0,0,30,0">
<Image.Source>
<FontImageSource
FontFamily="MISHRP"
Glyph="{StaticResource PowerIcon}"
Color="White"/>
</Image.Source>
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="LogOut_Tapped" />
</Image.GestureRecognizers>
</Image>
</Grid>
該Settings_Tapped方法如下所示:
async void Settings_Tapped(object sender, EventArgs e)
{
await Shell.Current.GoToAsync(nameof(SettingsPage));
}
而這SettingsPage只是一個TabbedPage. 此設定有效,但正如我所說,我確實在頁面頂部獲得了“回傳”按鈕。我希望“設定”頁面的外觀和行為與應用程式中的任何其他頁面一樣。
順便說一句,我嘗試添加NavigationPage.SetHasBackButton(SettingsPage, false);,但這給了我一個錯誤。上面寫著:
'SettingsPage' 是一種型別,在給定的背景關系中無效
知道如何使我SettingsPage的外觀和行為像任何其他頁面嗎?
uj5u.com熱心網友回復:
其他頁面是包裹在 ShellContent 中的專案,如果使用 GoToAsync,新頁面和主頁面將不會顯示在堆疊的同一層。因此您可以包裝設定頁面并在單擊按鈕時更改當前專案,例如:
在圣誕節:
<FlyoutItem Title="." IsVisible="False" x:Name="mysettings"> <ShellContent Route="ItemsPage" ContentTemplate="{DataTemplate local:SettingsPage}" /> </FlyoutItem>按鈕點擊:
Shell.Current.CurrentItem=mysettings;
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/465919.html
