Skip to content

TabView breaks custom titlebar drag region since SDK1.6 #10435

@Mutad0r

Description

@Mutad0r

Describe the bug

I was directed here with this issue from stackoverflow.

Adding or removing a tab to the tabview breaks the drag region of a custom title bar.
Every add or remove flips the behaviour as if a boolean is flipped. If it was working, it breaks, and if it was broken, it starts working again.

I tried different versions of the SDK. Bug seems to exist in all versions from 1.6 onwards. Last version of 1.5 does not have the bug.

Steps to reproduce the bug

1: Implement the code below and run.
2: Add a tab
3: Drag region is now broken
4: Add a tab
5: Drag region is now working
6: Repeat steps 2-5

Minimum code to reproduce:
XAML:

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

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="48"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TabView Grid.Row="1" AddTabButtonClick="TabView_AddTabButtonClick"/>
    </Grid>
</Window>

C#:

namespace TitleBar_Bug_Test
{
    public sealed partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();

            Microsoft.UI.Windowing.AppWindow appWindow = this.AppWindow;
            var titleBar = appWindow.TitleBar;
            titleBar.ExtendsContentIntoTitleBar = true;
            titleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
        }

        private void TabView_AddTabButtonClick(TabView sender, object args)
        {
            var newTab = new TabViewItem();
            newTab.IconSource = new SymbolIconSource() { Symbol = Symbol.Document };
            newTab.Header = "New Page";

            // The Content of a TabViewItem is often a frame which hosts a page.
            Frame frame = new Frame();
            newTab.Content = frame;
            frame.Navigate(typeof(TestPage));

            sender.TabItems.Add(newTab);
        }
    }
}

Expected behavior

Drag region of the custom title bar is not affected by the TabView, which has nothing to do with the title bar.

Screenshots

TabViewBug.mp4

NuGet package version

None

Windows version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageIssue needs to be triaged by the area owners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions