Xamarin.Forms Xamarin ネイティブ プロジェクト
通常、 Xamarin.Forms アプリケーションには から ContentPage
派生した 1 つ以上のページが含まれており、これらのページは .NET Standard ライブラリ プロジェクトまたは共有プロジェクト内のすべてのプラットフォームで共有されます。 ただし、ネイティブ フォームを使用すると ContentPage
、派生ページをネイティブ Xamarin.iOS、Xamarin.Android、UWP アプリケーションに直接追加できます。 ネイティブ プロジェクトで .NET Standard ライブラリ プロジェクトまたは共有プロジェクトから派生したページを使用 ContentPage
する場合と比較すると、ネイティブ プロジェクトにページを直接追加する利点は、ページをネイティブ ビューで拡張できることです。 その後、XAML で ネイティブ ビューに という名前を付 x:Name
け、分離コードから参照できます。 ネイティブ ビューの詳細については、「ネイティブ ビュー」を参照してください。
ネイティブ プロジェクトで派生ページを Xamarin.FormsContentPage
使用するプロセスは次のとおりです。
- NuGet パッケージを Xamarin.Forms ネイティブ プロジェクトに追加します。
ContentPage
派生ページと依存関係をネイティブ プロジェクトに追加します。Forms.Init
メソッドを呼び出します。- 派生ページのインスタンスを
ContentPage
構築し、iOS、Android、または UWP のいずれかの拡張メソッドCreateViewController
を使用して、CreateSupportFragment
CreateFrameworkElement
適切なネイティブ型に変換します。 - ネイティブ ナビゲーション API を使用して、派生ページの
ContentPage
ネイティブ型表現に移動します。
Xamarin.Forms ネイティブ プロジェクトが派生ページを構築するには、 Forms.Init
メソッドを呼び出して初期化する ContentPage
必要があります。 これを行うタイミングの選択は、主にアプリケーション フローで最も便利なタイミングによって異なります。これは、アプリケーションの起動時、または派生ページが構築される直前に ContentPage
実行される可能性があります。 この記事と付属のサンプル アプリケーションでは、アプリケーションの起動時に Forms.Init
メソッドが呼び出されます。
注意
NativeForms サンプル アプリケーション ソリューションには、プロジェクトがXamarin.Forms含まれていません。 代わりに、Xamarin.iOS プロジェクト、Xamarin.Android プロジェクト、UWP プロジェクトで構成されます。 各プロジェクトは、ネイティブ フォームを使用して派生ページを使用 ContentPage
するネイティブ プロジェクトです。 ただし、ネイティブ プロジェクトが .NET Standard ライブラリ プロジェクトまたは共有プロジェクトから派生したページを使用 ContentPage
できなかった理由はありません。
ネイティブ フォーム、Xamarin.Formsデータ バインディング エンジンなどのDependencyService
MessagingCenter
機能を使用する場合は、すべて引き続き機能します。 ただし、ページ ナビゲーションはネイティブ ナビゲーション API を使用して実行する必要があります。
iOS
iOS では、 FinishedLaunching
通常、 クラスの AppDelegate
オーバーライドは、アプリケーションの起動関連タスクを実行する場所です。 アプリケーションの起動後に呼び出され、通常はオーバーライドされ、メイン ウィンドウとビュー コントローラーを構成します。 次のコード例は、サンプル アプリケーションの AppDelegate
クラスを示しています。
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
public static AppDelegate Instance;
UIWindow _window;
AppNavigationController _navigation;
public static string FolderPath { get; private set; }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
Forms.Init();
// Create app-level resource dictionary.
Xamarin.Forms.Application.Current = new Xamarin.Forms.Application();
Xamarin.Forms.Application.Current.Resources = new MyDictionary();
Instance = this;
_window = new UIWindow(UIScreen.MainScreen.Bounds);
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes
{
TextColor = UIColor.Black
});
FolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
NotesPage notesPage = new NotesPage()
{
// Set the parent so that the app-level resource dictionary can be located.
Parent = Xamarin.Forms.Application.Current
};
UIViewController notesPageController = notesPage.CreateViewController();
notesPageController.Title = "Notes";
_navigation = new AppNavigationController(notesPageController);
_window.RootViewController = _navigation;
_window.MakeKeyAndVisible();
notesPage.Parent = null;
return true;
}
// ...
}
FinishedLaunching
メソッドは、次のタスクを実行します。
- Xamarin.Forms は、 メソッドを
Forms.Init
呼び出すことによって初期化されます。 - 新
Xamarin.Forms.Application
しい is オブジェクトが作成され、そのアプリケーション レベルのリソース ディクショナリが XAML で定義されている にResourceDictionary
設定されます。 - クラスへの
AppDelegate
参照が フィールドにstatic
Instance
格納されます。 これは、 クラスで定義されているメソッドを他のクラスが呼び出すメカニズムをAppDelegate
提供するためです。 UIWindow
ネイティブ iOS アプリケーションのビューのメイン コンテナーである が作成されます。- プロパティは
FolderPath
、メモ データが格納されるデバイス上のパスに初期化されます。 NotesPage
XAML で定義された派生ページである Xamarin.FormsContentPage
オブジェクトが作成され、その親が以前に作成Xamarin.Forms.Application
されたオブジェクトに設定されます。- オブジェクトは
NotesPage
、 拡張メソッドを使用して にCreateViewController
UIViewController
変換されます。 Title
のUIViewController
プロパティが 設定され、 にUINavigationBar
表示されます。AppNavigationController
は、階層ナビゲーションを管理するために作成されます。 これは、 からUINavigationController
派生したカスタム ナビゲーション コントローラー クラスです。 オブジェクトはAppNavigationController
ビュー コントローラーのスタックを管理しUIViewController
、 が読み込まれるとAppNavigationController
、コンストラクターに渡された が最初に表示されます。- オブジェクトは
AppNavigationController
の最上位レベルUIViewController
UIWindow
として設定され、UIWindow
はアプリケーションのキー ウィンドウとして設定され、表示されます。 Parent
メモリ リークを防ぐために、NotesPage
オブジェクトの プロパティが にnull
設定されています。
メソッドが FinishedLaunching
実行されると、次のスクリーンショットに示すように、 クラスで Xamarin.FormsNotesPage
定義されている UI が表示されます。
重要
すべてのContentPage
派生ページは、ページの プロパティが オブジェクトに設定されているParent
場合、アプリケーション レベル ResourceDictionary
で定義されているリソースをApplication
使用できます。
をタップ +Button
するなどして UI を操作すると、分離コードで次のイベント ハンドラーが NotesPage
実行されます。
void OnNoteAddedClicked(object sender, EventArgs e)
{
AppDelegate.Instance.NavigateToNoteEntryPage(new Note());
}
static
AppDelegate.Instance
フィールドを使用するとAppDelegate.NavigateToNoteEntryPage
、 メソッドを呼び出すことができます。これは、次のコード例に示されています。
public void NavigateToNoteEntryPage(Note note)
{
NoteEntryPage noteEntryPage = new NoteEntryPage
{
BindingContext = note,
// Set the parent so that the app-level resource dictionary can be located.
Parent = Xamarin.Forms.Application.Current
};
var noteEntryViewController = noteEntryPage.CreateViewController();
noteEntryViewController.Title = "Note Entry";
_navigation.PushViewController(noteEntryViewController, true);
noteEntryPage.Parent = null;
}
メソッドはNavigateToNoteEntryPage
、Xamarin.FormsContentPage
-derived ページを 拡張メソッドをCreateViewController
使用して にUIViewController
変換し、 の プロパティをTitle
設定しますUIViewController
。 UIViewController
次に、 メソッドによって にAppNavigationController
プッシュされますPushViewController
。 そのため、次のスクリーンショットに Xamarin.FormsNoteEntryPage
示すように、 クラスで定義されている UI が表示されます。
NoteEntryPage
が表示されると、戻るナビゲーションは から AppNavigationController
クラスの をUIViewController
NoteEntryPage
ポップし、 から クラスの にユーザーをUIViewController
NotesPage
返します。 ただし、iOS ネイティブ ナビゲーション スタックから をUIViewController
ポップしても、 オブジェクトとアタッチされた Page
オブジェクトはUIViewController
自動的に破棄されません。 したがって、 クラスは AppNavigationController
、 メソッドを PopViewController
オーバーライドして、後方ナビゲーションでビュー コントローラーを破棄します。
public class AppNavigationController : UINavigationController
{
//...
public override UIViewController PopViewController(bool animated)
{
UIViewController topView = TopViewController;
if (topView != null)
{
// Dispose of ViewController on back navigation.
topView.Dispose();
}
return base.PopViewController(animated);
}
}
オーバーライドは PopViewController
、 Dispose
iOS ネイティブ ナビゲーション スタックからポップされた オブジェクトの メソッド UIViewController
を呼び出します。 これを行わないと、 UIViewController
オブジェクトとアタッチされているオブジェクトが Page
孤立します。
重要
孤立したオブジェクトはガベージ コレクションできないため、メモリ リークが発生します。
Android
Android では、 OnCreate
クラスの MainActivity
オーバーライドは通常、アプリケーションの起動関連タスクを実行する場所です。 次のコード例は、サンプル アプリケーションの MainActivity
クラスを示しています。
public class MainActivity : AppCompatActivity
{
public static string FolderPath { get; private set; }
public static MainActivity Instance;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Forms.Init(this, bundle);
// Create app-level resource dictionary.
Xamarin.Forms.Application.Current = new Xamarin.Forms.Application();
Xamarin.Forms.Application.Current.Resources = new MyDictionary();
Instance = this;
SetContentView(Resource.Layout.Main);
var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
SupportActionBar.Title = "Notes";
FolderPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData));
NotesPage notesPage = new NotesPage()
{
// Set the parent so that the app-level resource dictionary can be located.
Parent = Xamarin.Forms.Application.Current
};
AndroidX.Fragment.App.Fragment notesPageFragment = notesPage.CreateSupportFragment(this);
SupportFragmentManager
.BeginTransaction()
.Replace(Resource.Id.fragment_frame_layout, mainPage)
.Commit();
//...
notesPage.Parent = null;
}
...
}
OnCreate
メソッドは、次のタスクを実行します。
- Xamarin.Forms は、 メソッドを
Forms.Init
呼び出すことによって初期化されます。 - 新
Xamarin.Forms.Application
しい is オブジェクトが作成され、そのアプリケーション レベルのリソース ディクショナリが XAML で定義されている にResourceDictionary
設定されます。 - クラスへの
MainActivity
参照が フィールドにstatic
Instance
格納されます。 これは、 クラスで定義されているメソッドを他のクラスが呼び出すメカニズムをMainActivity
提供するためです。 - コンテンツは
Activity
レイアウト リソースから設定されます。 サンプル アプリケーションでは、レイアウトは、 を含むToolbar
と、フラグメント コンテナーとして機能する でFrameLayout
構成されますLinearLayout
。 Toolbar
が取得され、 のアクション バーActivity
として設定され、アクション バーのタイトルが設定されます。- プロパティは
FolderPath
、メモ データが格納されるデバイス上のパスに初期化されます。 NotesPage
XAML で定義された派生ページである Xamarin.FormsContentPage
オブジェクトが作成され、その親が以前に作成Xamarin.Forms.Application
されたオブジェクトに設定されます。- オブジェクトは
NotesPage
、 拡張メソッドを使用して にCreateSupportFragment
Fragment
変換されます。 - クラスは
SupportFragmentManager
、 インスタンスFragment
を クラスの に置き換えるトランザクションをFrameLayout
作成してNotesPage
コミットします。 Parent
メモリ リークを防ぐために、NotesPage
オブジェクトの プロパティが にnull
設定されています。
フラグメントの詳細については、「 フラグメント」を参照してください。
メソッドが OnCreate
実行されると、次のスクリーンショットに示すように、 クラスで Xamarin.FormsNotesPage
定義されている UI が表示されます。
重要
すべてのContentPage
派生ページは、ページの プロパティが オブジェクトに設定されているParent
場合、アプリケーション レベル ResourceDictionary
で定義されているリソースをApplication
使用できます。
をタップ +Button
するなどして UI を操作すると、分離コードで次のイベント ハンドラーが NotesPage
実行されます。
void OnNoteAddedClicked(object sender, EventArgs e)
{
MainActivity.Instance.NavigateToNoteEntryPage(new Note());
}
static
MainActivity.Instance
フィールドを使用するとMainActivity.NavigateToNoteEntryPage
、 メソッドを呼び出すことができます。これは、次のコード例に示されています。
public void NavigateToNoteEntryPage(Note note)
{
NoteEntryPage noteEntryPage = new NoteEntryPage
{
BindingContext = note,
// Set the parent so that the app-level resource dictionary can be located.
Parent = Xamarin.Forms.Application.Current
};
AndroidX.Fragment.App.Fragment noteEntryFragment = noteEntryPage.CreateSupportFragment(this);
SupportFragmentManager
.BeginTransaction()
.AddToBackStack(null)
.Replace(Resource.Id.fragment_frame_layout, noteEntryFragment)
.Commit();
noteEntryPage.Parent = null;
}
メソッドはNavigateToNoteEntryPage
、ContentPage
Xamarin.Forms-derived ページを 拡張メソッドをCreateSupportFragment
使用して にFragment
変換し、 をフラグメント バック スタックに追加Fragment
します。 そのため、次のスクリーンショットに示すように、 で Xamarin.FormsNoteEntryPage
定義されている UI が表示されます。
NoteEntryPage
が表示されたら、戻る矢印をタップすると、フラグメントのバック スタックから の がFragment
NoteEntryPage
ポップされ、ユーザーが クラスの NotesPage
にFragment
戻ります。
戻るナビゲーションのサポートを有効にする
SupportFragmentManager
クラスには、BackStackChanged
フラグメント バック スタックの内容が変更されるたびに発生するイベントがあります。 OnCreate
クラスの メソッドには、MainActivity
このイベントの匿名イベント ハンドラーが含まれています。
SupportFragmentManager.BackStackChanged += (sender, e) =>
{
bool hasBack = SupportFragmentManager.BackStackEntryCount > 0;
SupportActionBar.SetHomeButtonEnabled(hasBack);
SupportActionBar.SetDisplayHomeAsUpEnabled(hasBack);
SupportActionBar.Title = hasBack ? "Note Entry" : "Notes";
};
フラグメント バック スタックに 1 つ以上 Fragment
のインスタンスがある場合、このイベント ハンドラーはアクション バーに戻るボタンを表示します。 [戻る] ボタンをタップする応答は、オーバーライドによって OnOptionsItemSelected
処理されます。
public override bool OnOptionsItemSelected(Android.Views.IMenuItem item)
{
if (item.ItemId == global::Android.Resource.Id.Home && SupportFragmentManager.BackStackEntryCount > 0)
{
SupportFragmentManager.PopBackStack();
return true;
}
return base.OnOptionsItemSelected(item);
}
オーバーライドは OnOptionsItemSelected
、オプション メニューの項目が選択されるたびに呼び出されます。 この実装は、戻るボタンが選択されていて、フラグメント バック スタックに 1 つ以上 Fragment
のインスタンスがある場合に、フラグメント バック スタックから現在のフラグメントをポップします。
複数のアクティビティ
アプリケーションが複数のアクティビティで構成されている場合、 ContentPage
派生ページを各アクティビティに埋め込むことができます。 このシナリオでは、 メソッドはForms.Init
、 をOnCreate
埋め込むXamarin.FormsContentPage
最初Activity
の のオーバーライドでのみ呼び出す必要があります。 ただし、これには次の影響があります。
- の
Xamarin.Forms.Color.Accent
値は、 メソッドをActivity
呼び出Forms.Init
した から取得されます。 - の
Xamarin.Forms.Application.Current
値は、 メソッドを呼び出した にForms.Init
Activity
関連付けられます。
ファイルの選択
HTML の [ファイルの ContentPage
選択] ボタンをサポートする必要がある を使用 WebView
する派生ページを埋め込む場合は、 Activity
メソッドをオーバーライド OnActivityResult
する必要があります。
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
ActivityResultCallbackRegistry.InvokeCallback(requestCode, resultCode, data);
}
UWP
UWP では、 App
ネイティブ クラスは通常、アプリケーションスタートアップ関連のタスクを実行する場所です。 Xamarin.Formsは通常、UWP アプリケーションではXamarin.Forms、ネイティブ App
クラスの OnLaunched
オーバーライドで 初期化され、 メソッドに引数をLaunchActivatedEventArgs
Forms.Init
渡します。 このため、派生ページを使用Xamarin.FormsContentPage
するネイティブ UWP アプリケーションでは、 メソッドから メソッドを最も簡単にForms.Init
App.OnLaunched
呼び出すことができます。
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// ...
Xamarin.Forms.Forms.Init(e);
// Create app-level resource dictionary.
Xamarin.Forms.Application.Current = new Xamarin.Forms.Application();
Xamarin.Forms.Application.Current.Resources = new MyDictionary();
// ...
}
さらに、 メソッドは OnLaunched
、アプリケーションに必要なアプリケーション レベルのリソース ディクショナリを作成することもできます。
既定では、ネイティブ App
クラスは、アプリケーションの MainPage
最初のページとして クラスを起動します。 次のコード例は、サンプル アプリケーションの MainPage
クラスを示しています。
public sealed partial class MainPage : Page
{
NotesPage notesPage;
NoteEntryPage noteEntryPage;
public static MainPage Instance;
public static string FolderPath { get; private set; }
public MainPage()
{
this.NavigationCacheMode = NavigationCacheMode.Enabled;
Instance = this;
FolderPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData));
notesPage = new Notes.UWP.Views.NotesPage
{
// Set the parent so that the app-level resource dictionary can be located.
Parent = Xamarin.Forms.Application.Current
};
this.Content = notesPage.CreateFrameworkElement();
// ...
notesPage.Parent = null;
}
// ...
}
コンストラクターは MainPage
、次のタスクを実行します。
- ページに対してキャッシュが有効になっているため、ユーザーがページに戻ったときに新しい
MainPage
が作成されません。 - クラスへの
MainPage
参照が フィールドにstatic
Instance
格納されます。 これは、他のクラスが クラスで定義されているメソッドを呼び出すメカニズムをMainPage
提供するためです。 - プロパティは
FolderPath
、メモ データが格納されるデバイス上のパスに初期化されます。 NotesPage
XAML で定義された派生ページである Xamarin.FormsContentPage
オブジェクトが作成され、その親が以前に作成Xamarin.Forms.Application
されたオブジェクトに設定されます。- オブジェクトは
NotesPage
拡張メソッドを使用して にFrameworkElement
CreateFrameworkElement
変換され、 クラスのMainPage
コンテンツとして設定されます。 Parent
メモリ リークを防ぐために、NotesPage
オブジェクトの プロパティが にnull
設定されています。
コンストラクターが MainPage
実行されると、次のスクリーンショットに示すように、 クラスで Xamarin.FormsNotesPage
定義されている UI が表示されます。
重要
すべてのContentPage
派生ページは、ページの プロパティが オブジェクトに設定されているParent
場合、アプリケーション レベルResourceDictionary
で定義されているリソースをApplication
使用できます。
をタップ +Button
するなどして UI を操作すると、コードビハインドで次のイベント ハンドラーが NotesPage
実行されます。
void OnNoteAddedClicked(object sender, EventArgs e)
{
MainPage.Instance.NavigateToNoteEntryPage(new Note());
}
static
MainPage.Instance
フィールドを使用すると、 MainPage.NavigateToNoteEntryPage
メソッドを呼び出すことができます。これは、次のコード例に示されています。
public void NavigateToNoteEntryPage(Note note)
{
noteEntryPage = new Notes.UWP.Views.NoteEntryPage
{
BindingContext = note,
// Set the parent so that the app-level resource dictionary can be located.
Parent = Xamarin.Forms.Application.Current
};
this.Frame.Navigate(noteEntryPage);
noteEntryPage.Parent = null;
}
UWP のナビゲーションは通常、 メソッドを使用して Frame.Navigate
実行され、引数を Page
受け取ります。 Xamarin.Forms は、 Frame.Navigate
派生ページ インスタンスを ContentPage
受け取る拡張メソッドを定義します。 したがって、 メソッドを NavigateToNoteEntryPage
実行すると、次のスクリーンショットに示すように、 で Xamarin.FormsNoteEntryPage
定義されている UI が表示されます。
NoteEntryPage
が表示されたら、戻る矢印をタップすると、アプリ内のバック スタックから の がポップFrameworkElement
NoteEntryPage
され、 クラスの にFrameworkElement
ユーザーがNotesPage
返されます。
ページサイズ変更のサポートを有効にする
UWP アプリケーション ウィンドウのサイズを変更すると、コンテンツの Xamarin.Forms サイズも変更されます。 これは、イベントのイベント ハンドラー Loaded
をコンストラクターに MainPage
登録することによって実現されます。
public MainPage()
{
// ...
this.Loaded += OnMainPageLoaded;
// ...
}
イベントは Loaded
、ページがレイアウトされ、レンダリングされ、対話の準備ができたときに発生し、応答として メソッドを OnMainPageLoaded
実行します。
void OnMainPageLoaded(object sender, RoutedEventArgs e)
{
this.Frame.SizeChanged += (o, args) =>
{
if (noteEntryPage != null)
noteEntryPage.Layout(new Xamarin.Forms.Rectangle(0, 0, args.NewSize.Width, args.NewSize.Height));
else
notesPage.Layout(new Xamarin.Forms.Rectangle(0, 0, args.NewSize.Width, args.NewSize.Height));
};
}
メソッドはOnMainPageLoaded
、イベントの匿名イベント ハンドラーをFrame.SizeChanged
登録します。これは、 または ActualWidth
プロパティが ActualHeight
で変更されたときに発生しますFrame
。 応答として、 メソッドを Xamarin.Forms 呼び出すことによって、アクティブなページのコンテンツのサイズが Layout
変更されます。
戻るナビゲーションのサポートを有効にする
UWP では、アプリケーションは、さまざまなデバイス フォーム ファクターにわたって、すべてのハードウェアとソフトウェアの戻るボタンの戻るナビゲーションを有効にする必要があります。 これは、コンストラクターでMainPage
実行できる イベントのイベント ハンドラーをBackRequested
登録することによって実現できます。
public MainPage()
{
// ...
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
}
アプリケーションが起動されると、メソッドは現在の GetForCurrentView
ビューに SystemNavigationManager
関連付けられているオブジェクトを取得し、イベントのイベント ハンドラーを BackRequested
登録します。 アプリケーションは、フォアグラウンド アプリケーションの場合にのみこのイベントを受け取り、応答としてイベント ハンドラーを OnBackRequested
呼び出します。
void OnBackRequested(object sender, BackRequestedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame.CanGoBack)
{
e.Handled = true;
rootFrame.GoBack();
noteEntryPage = null;
}
}
イベント ハンドラーは OnBackRequested
、アプリケーションの GoBack
ルート フレームで メソッドを呼び出し、 プロパティを BackRequestedEventArgs.Handled
に true
設定してイベントを処理済みとしてマークします。 イベントを処理済みとしてマークしないと、イベントが無視される可能性があります。
アプリケーションは、タイトル バーに [戻る] ボタンを表示するかどうかを選択します。 これは、 クラスで プロパティを AppViewBackButtonVisibility
列挙値のいずれかに AppViewBackButtonVisibility
設定することで実現されます App
。
void OnNavigated(object sender, NavigationEventArgs e)
{
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
((Frame)sender).CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
}
イベントの発生に応答してNavigated
実行されるイベント ハンドラーはOnNavigated
、ページ ナビゲーションが発生したときにタイトル バーの [戻る] ボタンの可視性を更新します。 これにより、アプリ内のバック スタックが空でない場合はタイトル バーの [戻る] ボタンが表示され、アプリ内のバック スタックが空の場合はタイトル バーから削除されます。
UWP のバック ナビゲーション サポートの詳細については、「UWP アプリの ナビゲーション履歴と後方ナビゲーション」を参照してください。