2017-05-04 52 views
0

我使用的模板10和Windows 10移动的时候,我选择了光模式全白,通知栏显示全白通知栏会出现在光模式

http://imgur.com/F6T7TKy.png

和不能看到的通知,小时等

在暗模式似乎一切良好形象:

http://imgur.com/j7nXoee.png

我该如何解决这个问题?

+0

正确的,因为你没有发送的状态栏的背景颜色。它不是自动处理的。该框架没有考虑到这一点,不认为它会永远。留给开发者,因为它可能是一个对比色或相近色调的默认 – mvermef

回答

1

我做这在我的汉堡包的倍率为UIElement CreateRootElement()我的数据库设置后/迁移完成。

if(Template10.Utils.DeviceUtils.Current().IsPhone()){ 
    var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); 
    if(statusBar != null) 
    { 
     if(Application.Current.RequestedTheme == ApplicationTheme.Light) 
      //background && foreground or combination, and dependent on color choices 
      statusBar.ForegroundColor = Windows.UI.Colors.Black; 
     else if(Application.Current.RequestedTheme == ApplicationTheme.Dark 
      statusBar.ForegroundColor = Windows.UI.Colors.White; 
    } 
} 

Template10已经有很多内置的逻辑只需要知道它在哪里。正如@Jay佐说你要还包括移动的基准以及..

+0

非常感谢!这解决了这个问题。 我只有一个问题,例如:如果应用程序的主题是黑暗的,我改变光的主题,它只有当我关闭和打开应用程序更新状态栏。当我更改应用程序主题时,有什么方法可以更新状态栏吗? –

+0

存在一些代码异味片段,但它需要稍微改变基本的T10代码以促进这种改变。不幸的是,当前的GitHub存储库现在还没有形成,因为该库目前正在通过代码重构进行分支和尝试更改。 – mvermef

+0

谢谢!另一个问题,这是可能的吗?当主题较亮时: 'statusBar.BackgroundColor = Colors.Black; statusBar.ForegroundColor = Colors.White;' –

1

正如@mvermef说,要解决这个问题,我们可以设置根据应用程序的主题在状态栏中使用的颜色。我们可以通过使用Application.RequestedTheme属性来获取应用程序的主题,并通过使用Status​Bar类中的属性来设置状态栏的颜色。举个简单的例子:

public MainPage() 
{ 
    InitializeComponent(); 
    NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled; 

    if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) 
    { 
     var statusBar = StatusBar.GetForCurrentView(); 
     if (statusBar != null) 
     { 
      if (Application.Current.RequestedTheme == ApplicationTheme.Light) 
      { 
       statusBar.ForegroundColor = Windows.UI.Colors.Black; 
      } 
      else if (Application.Current.RequestedTheme == ApplicationTheme.Dark) 
      { 
       statusBar.ForegroundColor = Windows.UI.Colors.White; 
      } 
     } 
    } 
} 

请注意使用Status​Bar类,我们需要参考的Windows Mobile扩展了UWP项目。

+0

拟定了以下Template10 ... – mvermef

+0

我把我的代码文件中:App.xaml.cs在公共覆盖异步任务OnStartAsync(StartKind startKind, IActivatedEventArgs args)。在你的例子中你在MainPage中有这个代码。有区别吗? –

+0

@FernandoSousa我把它放在MainPage中。在'OnStartAsync'中使用它也应该有效。 –