Skip to content

Commit 377d134

Browse files
authored
[File Locksmith] Using TitleBar (#41419)
## Summary of the Pull Request Using TitleBar instead of our custom XAML. No visual changes: <img width="1205" height="288" alt="image" src="https://github.com/user-attachments/assets/a41cf33d-7af7-4f4e-88e5-07cc1c47f09d" /> <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] Closes: #41414 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
1 parent be160d9 commit 377d134

File tree

3 files changed

+14
-43
lines changed

3 files changed

+14
-43
lines changed

src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithXAML/MainWindow.xaml

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,15 @@
2020
<RowDefinition Height="Auto" />
2121
<RowDefinition Height="*" />
2222
</Grid.RowDefinitions>
23-
<Grid
24-
x:Name="AppTitleBar"
25-
Height="32"
26-
ColumnSpacing="16">
27-
<Grid.ColumnDefinitions>
28-
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0" />
29-
<ColumnDefinition x:Name="IconColumn" Width="Auto" />
30-
<ColumnDefinition x:Name="TitleColumn" Width="Auto" />
31-
<ColumnDefinition x:Name="RightDragColumn" Width="*" />
32-
<ColumnDefinition x:Name="RightPaddingColumn" Width="0" />
33-
</Grid.ColumnDefinitions>
34-
<Image
35-
Grid.Column="1"
36-
Width="16"
37-
Height="16"
38-
VerticalAlignment="Center"
39-
Source="../Assets/FileLocksmith/Icon.ico" />
40-
<TextBlock
41-
x:Name="AppTitleTextBlock"
42-
Grid.Column="2"
43-
VerticalAlignment="Center"
44-
Style="{StaticResource CaptionTextBlockStyle}" />
45-
</Grid>
46-
23+
<TitleBar x:Name="titleBar">
24+
<!-- This is a workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/10374, once fixed we should just be using IconSource -->
25+
<TitleBar.LeftHeader>
26+
<ImageIcon
27+
Height="16"
28+
Margin="16,0,0,0"
29+
Source="/Assets/FileLocksmith/Icon.ico" />
30+
</TitleBar.LeftHeader>
31+
</TitleBar>
4732
<views:MainPage x:Name="mainPage" Grid.Row="1" />
4833
</Grid>
49-
</winuiex:WindowEx>
34+
</winuiex:WindowEx>

src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithXAML/MainWindow.xaml.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,16 @@ public MainWindow(bool isElevated)
1818
{
1919
InitializeComponent();
2020
mainPage.ViewModel.IsElevated = isElevated;
21+
SetTitleBar(titleBar);
2122
ExtendsContentIntoTitleBar = true;
22-
SetTitleBar(AppTitleBar);
23-
Activated += MainWindow_Activated;
23+
AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
2424
AppWindow.SetIcon("Assets/FileLocksmith/Icon.ico");
2525
WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(this.GetWindowHandle());
2626

2727
var loader = ResourceLoaderInstance.ResourceLoader;
2828
var title = isElevated ? loader.GetString("AppAdminTitle") : loader.GetString("AppTitle");
2929
Title = title;
30-
AppTitleTextBlock.Text = title;
31-
}
32-
33-
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
34-
{
35-
if (args.WindowActivationState == WindowActivationState.Deactivated)
36-
{
37-
AppTitleTextBlock.Foreground =
38-
(SolidColorBrush)App.Current.Resources["WindowCaptionForegroundDisabled"];
39-
}
40-
else
41-
{
42-
AppTitleTextBlock.Foreground =
43-
(SolidColorBrush)App.Current.Resources["WindowCaptionForeground"];
44-
}
30+
titleBar.Title = title;
4531
}
4632

4733
public void Dispose()

src/modules/FileLocksmith/FileLocksmithUI/FileLocksmithXAML/Views/MainPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
TextWrapping="Wrap" />
191191
</ContentDialog>
192192
<ContentDialog x:Name="ProcessFilesListDialog" x:Uid="ProcessFilesListDialog">
193-
<ScrollViewer Padding="15" HorizontalScrollBarVisibility="Auto">
193+
<ScrollViewer Padding="16" HorizontalScrollBarVisibility="Auto">
194194
<TextBlock
195195
x:Name="ProcessFilesListDialogTextBlock"
196196
x:Uid="ProcessFilesListDialogTextBlock"

0 commit comments

Comments
 (0)