question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[WinUI 3] Custom TitleBar Window Decorations not working

See original GitHub issue

I have enabled ExtendsContentIntoTitleBar = true; and created a custom title bar as follows:

        <Grid Name="TitleBar" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="30" Background="Transparent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>
                <ColumnDefinition/>
                <ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Column="1" Margin="20,8,0,0" Style="{StaticResource CaptionTextBlockStyle}" Text="{x:Bind ViewModel.Title}"/>
        </Grid>

I also set this title bar with SetTitleBar(TitleBar); This is the result: image As you can see, the window decorations (Minimize, Maximize, Close) are not the correct size as they are on every other Windows window and these buttons also don’t work (they seem to be disabled and don’t do anything when clicked). How can I get them to 1. be the correct size and 2. function correctly?

Btw, using the Windows App SDK V0.8.1 with WinUI 3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
crramirezcommented, Nov 25, 2021

@hayashida-katsutoshi Works perfectly. Thank you very much

1reaction
hayashida-katsutoshicommented, Nov 25, 2021
    <Grid Grid.RowDefinitions="Auto,*">
        <StackPanel Grid.Row="0" Height="35" Orientation="Horizontal" Spacing="15" x:Name="TitleBar" HorizontalAlignment="Stretch" VerticalAlignment="Top">
            <TextBlock VerticalAlignment="Center" Text="MyApp" />
        </StackPanel>
    </Grid>

I use this for the title bar and the Minimize/Maximize/Close are working on a Windows 10 PC. I tested it in WinUI3 unpackaged desktop with Windows App SDK 1.0.

You can add an icon inserting an Image tag before the TextBlock. The icon will have no context menu but fair enough to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom title bar not working in Unpackaged mode of ...
Hi, I have created Winui3vApp with custom title bar by using ... Custom title bar not working in Unpackaged mode of Winui3 in...
Read more >
How do I customize the Window Titlebar in a Windows App ...
I use the OverlapsedPresenter class to change some things about the window, like if it's resizable or not. Share.
Read more >
Why is it so incredibly complicated to make a custom title ...
Custom title bars are a good way to make sure anyone using your app is miserable because if you make one small mistake,...
Read more >
Winui Titlebar
Custom title bar not working in Unpackaged mode of Winui3 in. winui 3 title bar. ... There is no obvious way to control...
Read more >
3 apps, same PC - different title bar colours and highlights
The only way to change the title bar seems to be to change the theme to ... Certain Windows apps will not reflect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found