首页 > 解决方案 > UWP 扩展到标题栏 - 默认标题栏转换后退按钮

问题描述

在我的 UWP 应用程序中,我试图将后退按钮放入标题栏中,我过去曾多次这样做。这一次,我面临的问题是默认标题栏似乎并没有消失,而是悬停在我的按钮上,所以我无法按下它。我尝试创建一个带有边距的自定义标题栏,但这并没有解决它。这是延伸到标题栏...:

var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;

...和自定义标题栏:

var titleBarGrid = new Grid()
{
    Background = new SolidColorBrush(Colors.Transparent),
    HorizontalAlignment = HorizontalAlignment.Stretch,
    VerticalAlignment = VerticalAlignment.Top,
    Height = 48,
    Margin = new Thickness(50, 0, 150, 0),
};
Window.Current.SetTitleBar(titleBarGrid);

这些是在 App.xaml.cs 中设置的。

如何删除/覆盖默认标题栏?

标签: c#xamluwp

解决方案


不知何故,我通过移动settitlebar(grid)上面的InitializeComponent(). Martin - 如果我不设置颜色,它会使窗口不可拖动,然后除了最小化按钮的默认左侧外,没有什么可拖动的。我制作成标题栏的网格的边距不与我的任何按钮重叠。


推荐阅读