1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MAUI Tips - 戻るボタンの無効化

Posted at

概要

これまでXamarin.Formsで作っていたアプリを、一念発起して.NET MAUIで作り直す中で
調べたことの備忘録。

環境

Visual Studio for MAC
.NET MAUI
.NET 7

調べたこと

Microsoft LearnのNavigationPageのページに、「[戻る] ボタンを無効にする」という項目に記載があります。
ここには、「モーダル ページの Page.OnBackButtonPressed メソッドをオーバーライドします。」とだけ記載されています。
もう少し親切に書いてほしい・・・・。

実装内容

こんな感じです。
ContentPageの派生クラスで、OnBackButtonPressed関数をオーバーライド後、
ベースクラスのOnBackButtonPressed関数を呼ばず、
戻り値としてtrueを返すようにします。

    protected override bool OnBackButtonPressed()
    {
        //return base.OnBackButtonPressed();
        return true;
    }
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?