Xamarin.FormsのShellの遷移の種類(Modalかどうか)は遷移先の各ページで指定する
Shellは画面遷移の手段としてShell.Current.Navigation.PushAsync
などのこれまでのNavigationno方法もShell.Current.GoToAsync
も使えます.
Navigation.PushAsync系の遷移方法にはModalなページとして開くPushModalAsync
もあります.
しかし,Shell.Current.GoToAsync系にはModalで開くメソッドはありません.ではこちらの方法でModalで開くにはどうするかというと,遷移先のページで指定します.
<Content>
タグの開始タグに以下の1行を追加します.
Shell.PresentationMode="ModalAnimated"
このような感じです.
<?xml version="1.0" encoding="utf-8" ?> <ContentPage x:Class="XFShellRouting.Views.ElephantDetailPage" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Shell.PresentationMode="ModalAnimated" mc:Ignorable="d"> <ContentPage.Content> <StackLayout> <Label HorizontalOptions="CenterAndExpand" Text="Elephant Detail Page" VerticalOptions="CenterAndExpand" /> </StackLayout> </ContentPage.Content> </ContentPage>
これで,このページはModalで開かれます.
1つのページをModalで開いたり,そうじゃなかったりということはまあ無い気がしますので,ページそれ自体で定義するのはわかりやすいなと思いました.