You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

向TabView添加标签时自定义标题栏拖拽区域状态异常问题

问题:TabView添加标签页时标题栏拖拽区域状态反复切换且XAML调试工具栏跳动

当向TabView中添加新标签页时,标题栏拖拽区域(titlebar drag region)会在启用与禁用状态间反复切换,视觉上无明显变化,但每次添加标签都会触发该状态变更,同时XAML Debug toolbar会出现上下跳动的现象。

最小复现示例

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#代码

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

问题现象截图

工具栏跳动截图1
工具栏跳动截图2
工具栏跳动截图3

请问是否有人知晓该问题的成因?


内容的提问来源于stack exchange,提问作者MAabmets

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 08:47:39