トルネード

毛利のメモ書き

UWP 入門 - タイトルバーのボタンを透過

前回は、ExtendViewIntoTitleBar = trueにしてタイトルバーの非表示をしました。
引続きタイトルバーのボタンも透過します。 f:id:mojeld:20180729150913p:plain

上の図のように右上部のボタンが透過していることが確認できます。

App.xaml.csでのコード

右上部のボタンを透過するには、App.xaml.cs側で下記のようにコードを追加します。
最初に、Windows.UI.ViewManagementWindows.UIをusingする必要があります。

//using Windows.UI.ViewManagement;
//using Windows.UI;
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
    ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
    titleBar.ButtonBackgroundColor = Colors.Transparent;              //ボタンバックグラウンドの透過
    titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
    titleBar.ButtonForegroundColor = Colors.White;
//......

Imageが黒いので、ButtonForegroundColorはWhiteにしています。

参考

タイトル バーのカスタマイズ - UWP app developer | Microsoft Docs