ウィンドウコントロールをタイトルバーに拡張してクリック可能にする簡単な方法はありますか?UWPのタイトルバーへのボタンの拡張
私は関連記事(How to customize the application title bar for a UWP page)を読んでいます。タイトルバーの領域を視覚的に拡張する方法を理解しています。しかし、私のボタンはその領域ではクリックできません(あたかもその上にレイヤーがあり、クリックされないように)。
ウィンドウコントロールをタイトルバーに拡張してクリック可能にする簡単な方法はありますか?UWPのタイトルバーへのボタンの拡張
私は関連記事(How to customize the application title bar for a UWP page)を読んでいます。タイトルバーの領域を視覚的に拡張する方法を理解しています。しかし、私のボタンはその領域ではクリックできません(あたかもその上にレイヤーがあり、クリックされないように)。
もちろんの事、あなたがそこから
//draw into the title bar
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
//remove the solid-colored backgrounds behind the caption controls and system back button
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
で始まり、右のスペースにボタンを配置する事になるだろう。
アプリのタイトルを排除することになるので、これも参考になります。
<!-- Page attribute -->
xmlns:appmodel="using:Windows.ApplicationModel"
<TextBlock x:Name="AppTitle" Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind appmodel:Package.Current.DisplayName}" IsHitTestVisible="False"/>
その後、もちろん、あなたが戻るボタン運のベスト
CoreApplicationViewTitleBar titleBar = CoreApplication.GetCurrentView().TitleBar;
titleBar.LayoutMetricsChanged += TitleBar_LayoutMetricsChanged;
private void TitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args)
{
AppTitle.Margin = new Thickness(CoreApplication.GetCurrentView().TitleBar.SystemOverlayLeftInset + 12, 8, 0, 0);
}
の注意が必要になるでしょう!
その他:https://docs.microsoft .com/en-us/windows/uwp/style/title-bar –
これは実際の回答ではありませんが、この例を参考にしてください。https://www.eternalcoding.com/?p=1952 – Depechie