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.

Question: What is the proper usage ExtendContentIntoTitlebar and SetTitleBar

See original GitHub issue

Hi, I am trying to use the WinUI 3 preview to create a demo app that utilizes a custom titlebar. I followed the instructions here and the work around here to fix the unresponsive default caption buttons. Now the caption buttons work fine but the entire window is being treated as the title bar not just the TextBlock that I set to be the title bar with SetTitleBar() and additionally the two test buttons that I added are no longer clickable via the mouse and have to be clicked with a combination of the tab and space/enter keys

I have come to the conclusion that I might not be understanding the intended usage of the this functionality as I am still very new to XAML UI in general.

The code I am using is: App.xaml.cs

protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
        {
            m_window = new MainWindow();
            m_window.ExtendsContentIntoTitleBar = true;
            m_window.SetTitleBar(m_window.CustomTitleBar);
            m_window.Activate();
        }

MainWindow.xaml.cs

private void myButton_Click(object sender, RoutedEventArgs e)
        {
            myButton.Content = "Clicked";
        }
        private void myButton_Click2(object sender, RoutedEventArgs e)
        {
            myButton2.Content = "Clicked2";
        }

MainWindow.xaml

<Window
    x:Class="WinUI_3_practice.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WinUI_3_practice"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid x:Name="Content" x:FieldModifier="Public" IsHitTestVisible="False">
        <TextBlock x:Name="CustomTitleBar" x:FieldModifier="Public" HorizontalTextAlignment="Center" IsHitTestVisible="False">Custom title text</TextBlock>
        <StackPanel x:Name="StackPanel" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Button x:Name="myButton" Click="myButton_Click">Button 1</Button>
            <Button x:Name="myButton2" Click="myButton_Click2">Button 2</Button>
        </StackPanel>
    </Grid>
</Window>

Am I using this functionality incorrectly, or is this a bug of some kind? Thanks.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
marb2000commented, May 4, 2021

Hi there, Here you can find a sample about custom Title Bar. There a couple of bugs that depending on the layout (In this case the Grid) the caption buttons are no longer functionals. We are fixing these bugs for Reunion 0.8.

0reactions
sudonggcommented, Apr 6, 2021

I always thought it was a bug, because in the uwp application, it is possible to set any button on the upper layer of the title bar, until now it has become a “Stable Feature”. The current custom title can only set the appearance, it can’t meet my needs at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window.ExtendsContentIntoTitleBar Property
Gets or sets a value that specifies whether the default title bar of the window should be hidden to create space for app...
Read more >
How to set Icon and color for Winui3 Titlebar application?
Hi i am creating a winui3 application i want these 1.how to add icon to top right corner of title bar window 2.how...
Read more >
Custom Title bar showing up white-ish in WinUI 3
I'm back with another problem in my browser that I'm working on. I made a custom title bar ... I use ExtendsContentIntoTitleBar =...
Read more >
XAML Brewer, by Diederik Krols | If you're not having fun, you ...
The included sample app demonstrates how to use the right mouse button to draw a line on the map, and calculate and display...
Read more >
Untitled
If ExtendsContentIntoTitleBar is false, the call to SetTitleBar does … what ... ExtendsContentIntoTitleBar = true (you can use the WinUI 3 Gallery app...
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