Question: What is the proper usage ExtendContentIntoTitlebar and SetTitleBar
See original GitHub issueHi, 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:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
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.
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.