我正在尝试为 UWP 页面设置页面的应用程序标题栏始终可见,并禁用恢复按钮,但我没有找到与此相关的任何内容。
我所能做的就是更改具有如下代码的应用程序标题栏的颜色
public MainPage()
{
this.InitializeComponent();
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
ApplicationView.GetForCurrentView().Title = "TEST";
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ForegroundColor = Color.FromArgb(1, 1, 1, 1);
}
但这就是我所能做的......而且应用程序标题栏的标题表现得很奇怪,因为我将它设置为“TEST”但在 UI 上显示“ProjectName-TEST”。
那么,你知道我如何自定义(设置应用程序栏标题,将其设置为始终可见,而不仅仅是当用户将光标移动到页面顶部并禁用恢复按钮时(就像我可以拥有它一样在 Windows 窗体中))UWP 项目页面的应用程序标题栏?
最佳答案
目前无法禁用任何标题栏按钮(最小化、最大化等)。有 some discussion about this on GitHub您可以关注。
除此限制外,您还可以使用 ExtendViewIntoTitleBar 自定义标题栏。结合Window.Current.SetTitleBar .总之,这些允许您在标题栏中使用自定义 XAML:
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
...
Window.Current.SetTitleBar(myTitleBar);
GitHub 上有一个很好的引用资源(由 Microsoft 创建),其中显示了您可以自定义的内容:Title bar sample
The sample shows the following techniques:
Customizing the colors in the standard system title bar.
Extending the view into the title bar, so you can draw a custom title bar.
Responding to changes in title bar states.
Drawing controls in the title bar (XAML only).
这里有一些关于自定义标题栏的其他好教程:
关于c# - 如何自定义 UWP 页面的应用程序标题栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42042856/