2017-08-19 74 views
0

我试图使标题栏模糊,笔者走访了this页面并添加如下所示的Windows 10 UWP模糊标题栏

CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; 
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; 
titleBar.ButtonBackgroundColor = Colors.Transparent; 
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; 

代码,但显示的错误,我不知道如何解决这个

This is the error image

回答

0

您不能在应用程序做到这一点()。你应该避免在那里做任何事情。

建议最好的地方是使用你的第一页OnNavigatedTo方法。可能你可以做OnLaunched,但我没有测试过,因为你已经链接的页面使用App.xaml.cs建议它可能意味着OnLaunched,我不确定这是否始终是最佳实践,因为你的应用可能会打开多个窗户,然后它不会工作。

0

你应该在App.xaml.cs

protected override async void OnLaunched(LaunchActivatedEventArgs args) 
{ 
    CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; 
    ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; 
    titleBar.ButtonBackgroundColor = Colors.Transparent; 
    titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; 
} 
OnLaunchedOnActivated方法使用此代码