mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[RegistryPreview]Better theme support for caption bar (#25535)
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
<!-- Other merged dictionaries here -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- Need to set these to transparent to allow the custom title bar to be its real color -->
|
||||
<SolidColorBrush x:Key="WindowCaptionBackground">Transparent</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled">Transparent</SolidColorBrush>
|
||||
<!-- Other app resources here -->
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -513,12 +513,15 @@ namespace RegistryPreview
|
||||
string[] file = filename.Split('\\');
|
||||
if (file.Length > 0)
|
||||
{
|
||||
appWindow.Title = file[file.Length - 1] + " - " + APPNAME;
|
||||
titleBarText.Text = file[file.Length - 1] + " - " + APPNAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
appWindow.Title = filename + " - " + APPNAME;
|
||||
titleBarText.Text = filename + " - " + APPNAME;
|
||||
}
|
||||
|
||||
// Continue to update the window's title, after updating the custom title bar
|
||||
appWindow.Title = titleBarText.Text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -526,6 +529,7 @@ namespace RegistryPreview
|
||||
/// </summary>
|
||||
private void UpdateWindowTitle()
|
||||
{
|
||||
titleBarText.Text = APPNAME;
|
||||
appWindow.Title = APPNAME;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,31 @@
|
||||
<winuiex:WindowEx.Backdrop>
|
||||
<winuiex:MicaSystemBackdrop />
|
||||
</winuiex:WindowEx.Backdrop>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid
|
||||
x:Name="titleBar"
|
||||
Grid.Row="0"
|
||||
IsHitTestVisible="True">
|
||||
<StackPanel
|
||||
Margin="8,8,8,8"
|
||||
VerticalAlignment="Bottom"
|
||||
Orientation="Horizontal">
|
||||
<Image Source="app.ico"/>
|
||||
<TextBlock
|
||||
x:Name="titleBarText"
|
||||
Margin="8,0,0,0"
|
||||
FontSize="12"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding ApplicationTitle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
x:Name="gridPreview"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
@@ -45,7 +69,7 @@
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="8,8,8,8"
|
||||
Margin="8,0,8,8"
|
||||
CornerRadius="{StaticResource OverlayCornerRadius}"
|
||||
Style="{StaticResource GridCardStyle}">
|
||||
<CommandBar
|
||||
@@ -320,4 +344,5 @@
|
||||
GripperCursor="SizeNorthSouth"
|
||||
IsTabStop="False" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</winuiex:WindowEx>
|
||||
|
||||
@@ -6,7 +6,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.Data.Json;
|
||||
@@ -54,6 +53,10 @@ namespace RegistryPreview
|
||||
appWindow.SetIcon("app.ico");
|
||||
appWindow.Closing += AppWindow_Closing;
|
||||
|
||||
// Extend the canvas to include the title bar so the app can support theming
|
||||
ExtendsContentIntoTitleBar = true;
|
||||
SetTitleBar(titleBar);
|
||||
|
||||
// if have settings, update the location of the window
|
||||
if (jsonSettings != null)
|
||||
{
|
||||
|
||||
@@ -189,6 +189,9 @@
|
||||
<data name="textBox.PlaceholderText" xml:space="preserve">
|
||||
<value>Registry file text will appear here...</value>
|
||||
</data>
|
||||
<data name="titleBarText.ApplicationTitle" xml:space="preserve">
|
||||
<value>Registry Preview</value>
|
||||
</data>
|
||||
<data name="ToolTipAddedKey" xml:space="preserve">
|
||||
<value>Key will be added, if needed</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user