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 - ナビゲーションバーの消し方

Last updated at Posted at 2023-09-10

2023.09.10 記載に誤りがあったので(盛大に勘違いしてました)修正済み。

概要

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

環境

Visual Studio for MAC
.NET MAUI
.NET 7

問題となった現象

追加したContentPageのXAML側に、NavigationBarを消す処理を入れたけど、
消えない・・・。

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="PIYOTCloud.LoginPage"
             Title="LoginPage"
             Shell.NavBarIsVisible="false"
             >

調べたこと

上記のコードは、Microsoft Learnのページを見て追加しました。

これ、完全に私が悪いんですが、Shellを使う場合とNavigationPageを使う場合で、
ナビゲーションバーの指定の仕方が違うんですね。
→そりゃそうだ。

Shellを使っている場合は上記のコードでいいんですけど、
NavigationPageを使用している場合は、以下のように 
NavigationPage.HasNavigationBar="false" 」と指定する必要があります。

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="PIYOTCloud.LoginPage"
             Title="LoginPage"
             NavigationPage.HasNavigationBar="false"
             >

→ShellからNavigationPageに変えた段階で気づけよって話なんですけどね・・・。

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?