Skip to content

Conversation

@niels9001
Copy link
Collaborator

@niels9001 niels9001 commented Mar 8, 2025

DO NOT MERGE UNTIL WASDK 1.7 STABLE

Closes: #1736 #1798

Changes:

  • Introducing a new MainWindow.xaml in favor of creating a window in code-behind + NavigationRootPage.
  • Cleanup of unused code
  • Using the new TitleBar control: moving the pane toggle button and searchbox to the TitleBar following design best practices for Windows 11
  • Made the Copy link logic dynamic: in debug mode, the link will open the actual dev version of the Gallery for easier debugging.
  • Added samples for TitleBar

image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces a new MainWindow.xaml and refactors navigation and titlebar logic to follow design best practices for Windows 11. It also removes unused code and makes the copy link logic dynamic based on build configuration.

  • Migrates navigation calls from NavigationRootPage to App.MainWindow.
  • Updates version and theme parsing to use the new helper classes.
  • Adjusts URI schemes for protocol activation based on debug/release mode.

Reviewed Changes

File Description
WinUIGallery/Helpers/VersionHelper.cs Adds version details properties and retrieves Windows App Runtime version dynamically.
WinUIGallery/Helpers/EnumHelper.cs Provides a generic enum parsing helper to replace custom implementations.
WinUIGallery/App.xaml.cs Refactors window initialization and navigation to use MainWindow instead of a separate NavigationRootPage.
WinUIGallery/Helpers/ProtocolActivationClipboardHelper.cs Makes copy link logic dynamic by selecting the appropriate URI scheme.
WinUIGallery/Pages/* Updates various page navigations to reference the new MainWindow navigation APIs.
WinUIGallery/MainWindow.xaml.cs Consolidates navigation, titlebar, and window management logic into MainWindow.
WinUIGallery/Helpers/NavigationOrientationHelper.cs, ThemeHelper.cs, TitleBarHelper.cs Adjusts helper methods to align with changes in window and navigation handling.

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Copy link
Contributor

@Zakariathr22 Zakariathr22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that the TitleBar sample should also be updated in the same PR to describe the new TitleBar.

@Jay-o-Way
Copy link
Contributor

Jay-o-Way commented Mar 8, 2025

For me, I have issues with restoring a number of packages. Is there an issue with dev.azure.com?

@niels9001
Copy link
Collaborator Author

I suggest that the TitleBar sample should also be updated in the same PR to describe the new TitleBar.

Maybe better to that in a separate PR? I've created an tracking issue here: #1798

@niels9001 niels9001 requested a review from Zakariathr22 March 12, 2025 14:07
@niels9001 niels9001 changed the title [DRAFT] MainWindow.xaml + new TitleBar [DRAFT] MainWindow.xaml with new TitleBar + TitleBar samples Mar 12, 2025
@niels9001
Copy link
Collaborator Author

I suggest that the TitleBar sample should also be updated in the same PR to describe the new TitleBar.

@Zakariathr22 Since some of that old sample code was intertwined with the Gallery itself, I've created the new samples for TitleBar in this PR as well. Please review :)!

BorderBrush="{ThemeResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource OverlayCornerRadius}">
<TitleBar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should showcase TitleBar.LeftContent as well, so developers can see all the available customization options for the TitleBar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about that, but couldn't come up with a good use case really.. since the other content is RightContent I figured it's fine to show one of the two?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of adding something like a refresh button?

image

<TitleBar.LeftContent>
    <Border>
        <Border.Resources>
            <Style x:Key="TitleBarButtonStyle" TargetType="Button">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Margin" Value="2" />
                <Setter Property="Padding" Value="12,0" />
                <Setter Property="CornerRadius" Value="4" />
            </Style>
        </Border.Resources>
        <Button Style="{StaticResource TitleBarButtonStyle}">
            <FontIcon Glyph="&#xE72C;" FontSize="14"/>
            <ToolTipService.ToolTip>
                Refresh
            </ToolTipService.ToolTip>
        </Button>
    </Border>
</TitleBar.LeftContent>

Copy link
Contributor

@ghost1372 ghost1372 Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of adding something like a refresh button?

image

<TitleBar.LeftContent>
    <Border>
        <Border.Resources>
            <Style x:Key="TitleBarButtonStyle" TargetType="Button">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Margin" Value="2" />
                <Setter Property="Padding" Value="12,0" />
                <Setter Property="CornerRadius" Value="4" />
            </Style>
        </Border.Resources>
        <Button Style="{StaticResource TitleBarButtonStyle}">
            <FontIcon Glyph="&#xE72C;" FontSize="14"/>
            <ToolTipService.ToolTip>
                Refresh
            </ToolTipService.ToolTip>
        </Button>
    </Border>
</TitleBar.LeftContent>

How about adding a theme toggle button?
Or even better, display current user profile (PersonPicture)
Screenshot_۲۰۲۵۰۳۱۲_۲۱۲۸۱۰_Chrome.jpg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a theme toggle button?
Or even better, display current user profile (PersonPicture)

Do you mean adding it to the TitleBar sample example or the app's title bar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a theme toggle button?
Or even better, display current user profile (PersonPicture)

Do you mean adding it to the TitleBar sample example or the app's title bar?

I dont know, mybe, current user can be added in titlebar sample and theme toggle button in apps titlebar

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to have something that is not a button, so it stands out a bit more compared to the back and panetoggle buttons (as those come with the control by default).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to have something that is not a button, so it stands out a bit more compared to the back and panetoggle buttons (as those come with the control by default).

What about online/offline status?

image

<TitleBar.LeftContent>
    <FontIcon Glyph="&#xEA3B;" Foreground="{ThemeResource SystemFillColorSuccessBrush}"
              FontSize="14" Margin="12,0">
        <ToolTipService.ToolTip>
            Online
        </ToolTipService.ToolTip>
    </FontIcon>
</TitleBar.LeftContent>

Copy link
Contributor

@Jay-o-Way Jay-o-Way Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. I'm sure there is a better icon for that. And let's keep icon font size at 16.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And let's keep icon font size at 16.

The font size of the icons on TitleBar buttons is 14, which is why.

niels9001 and others added 3 commits March 12, 2025 16:36
Co-authored-by: Zakaria Tahri | Shade <101801384+Zakariathr22@users.noreply.github.com>
Co-authored-by: Zakaria Tahri | Shade <101801384+Zakariathr22@users.noreply.github.com>
Copy link
Contributor

@Zakariathr22 Zakariathr22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a more complex issue!
image
For more details, I reported it at microsoft/microsoft-ui-xaml#10427

My thoughts:
I think the TitleBar control is still far from being stable. I don't know if it will make it into WinAppSDK 1.7 stable or if it will be delayed to 1.8.

window.Activated += Window_Activated;
window.SetTitleBar(this.AppTitleBar);

AppWindow appWindow = WindowHelper.GetAppWindow(window);
Copy link
Contributor

@Zakariathr22 Zakariathr22 Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetAppWindow method can be removed from the helper class, as it's no longer needed with newer versions of WinAppSDK.

@niels9001 niels9001 closed this Jul 4, 2025
marcelwgn added a commit that referenced this pull request Jul 21, 2025
## Description
This PR creates a XAML-defined `MainWindow` for improved maintaining of
the shell UX going forward. It also uses the new `TitleBar` control and
moving the searchbox to the top of the window, following UX-guidance and
saving some vertical space in the NavView.

Closes: #1736

~~[DO NOT MERGE]: Blocked on `TitleBar` bugs~~

For TitleBar samples, see: #1797

---------

Co-authored-by: Zakaria Tahri <zakotahri@outlook.com>
Co-authored-by: Marcel Wagner <marcelwagner@microsoft.com>
Co-authored-by: Marcel W. <marcel.alex.wagner@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a MainWindow + new titlebar

5 participants