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?

.NET MAUI 10 の新機能を見ていく

Last updated at Posted at 2025-12-03

.NET MAUI Advent Calendar 2025 3日目の記事です。

概要

タイトル通り、.NET MAUI 10 の新機能を見ていきます。(本記事では、新機能・変更点のすべてではなく、私が興味があるものを取り上げています)

目次

  1. XAML が完結に書ける機能が追加
  2. [Android] 特別な設定で起動を高速化? (CoreCLR ランタイム/試験的な機能)
  3. [Android] dotnet run で簡単起動
  4. [Windows] 最小化ボタンと最大化ボタンを無効化できるように

新機能

1. XAML が完結に書ける機能が追加

https://devblogs.microsoft.com/dotnet/simpler-xaml-in-dotnet-maui-10/

.NET MAUI は、XAML と C# を組み合わせて書くのが一般的です。(C# のみにもできます)

今回のリリースでは、XAML を今までよりも簡潔に書く機能が追加されました!

手順としては、以下の記述を .csproj ファイルに追加するだけです。

<PropertyGroup>
    <DefineConstants>$(DefineConstants);MauiAllowImplicitXmlnsDeclaration</DefineConstants>
    <EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>

これによって、.xaml ファイルの先頭の記述を以下のように減らすことができます。

<ContentPage 
-   xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
-   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp.Pages.MyContentPage">
</ContentPage>

また、.xaml ファイル内の Communitytoolkit.Maui などで用いる <toolkit:MediaPlayer/> なども <MediaPlayer/> として省略できるようです。(これは別途 C# ファイルが必要かも?)

2. [Android] 特別な設定で起動を高速化?

https://learn.microsoft.com/dotnet/maui/whats-new/dotnet-10#experimental-coreclr

.NET MAUI は各リリースのたびに速度の改善や、容量の削減が進んでいます。

今回のリリースでは、Android 版で CoreCLR を用いた方法の実用化が進んだようです。(まだ試験的扱いですが)

アプリケーションサイズは非常に大きいようですが、「AOT コンパイルレベルの起動速度を出せた」という話もあります。(Reddit)

今後も、速度改善や容量削減に注目していきたいですね。

3. [Android] dotnet run で簡単起動

https://learn.microsoft.com/dotnet/maui/whats-new/dotnet-10#dotnet-run-support

本バージョンで、Android 版を dotnet run で簡単に起動できるようになりました。

# Android 物理デバイスが1つだけ接続されているとき
dotnet run -p:AdbTarget=-d

# Android エミュレータが1つだけ動いているとき
dotnet run -p:AdbTarget=-e

# Android 物理デバイスまたはエミュレータを指定して動かすとき
dotnet run -p:AdbTarget="-s emulator-5554"

今までは adb コマンドで接続後、dotnet build -t:Run ... で起動していたので、楽に開発できそうで嬉しいです。

4. [Windows] 最小化ボタンと最大化ボタンを無効化できるように

https://learn.microsoft.com/dotnet/maui/whats-new/dotnet-10#window

https://learn.microsoft.com/dotnet/maui/user-interface/controls/window#enable-or-disable-minimize-and-maximize-buttons-on-windows

Windows 限定ですが、最小化ボタンと最大化ボタンの有効・無効を切り替えられるようになりました。

#if WINDOWS
using Microsoft.Maui.Platform; // MauiWinUIWindow
using Microsoft.UI.Windowing;  // AppWindow, OverlappedPresenter

public static void ConfigureWindowButtons(Window window)
{
    var nativeWindow = (MauiWinUIWindow)window.Handler.PlatformView;
    var appWindow = nativeWindow.AppWindow;

    if (appWindow.Presenter is OverlappedPresenter presenter)
    {
        presenter.IsMinimizable = false; // 最小化ボタンを無効化
        presenter.IsMaximizable = false; // 最大化ボタンを無効化
    }
}
#endif

最小化・最大化ボタンではなく、ウィンドウ内の設定ページから変更してほしい場合などに使えそうです。

最後に

.NET MAUI 10 は、他にも様々な地道な改善が含まれています。開発者に感謝…!!

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?