MAabmets
MAabmets

Reputation: 25

WinUI3 Custom title bar drag region state changes when tab added to TabView

Whenever a new tab is added to the tabview, the titlebar drag region swaps between being enabled and disabled. Visually there is no change. Only effect is that the drag region becomes disabled or enabled any time a tab is added. The XAML Debug toolbar also jumps up and down whenever the change occurs.

I made a minimum implementation for the bug:

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>

CS:

    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);
        }
    }

Some pictures showing the toolbar jumping every time a tab is added:

enter image description here enter image description here enter image description here

Anybody have any idea what might cause this bug?

Upvotes: 0

Views: 43

Answers (0)

Related Questions