在整个应用程序中更改SystemTray颜色 - Windows Phone

时间:2015-06-16 07:02:30

标签: windows-phone-8 windows-phone system-tray

我想在整个应用程序中更改SystemTray背景和前景颜色,但我没有定义基页,现在我无法更改每个页面的颜色。有没有办法通过SystemTray

更改整个应用程序中App.xaml.cs的背景和前景色

1 个答案:

答案 0 :(得分:6)

Windows手机RT应用解决方案: 在App.xaml的OnLaunched方法中添加以下代码:

<?php
namespace Application\View\Helper;

use Zend\Mvc\Router\RouteMatch;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class RouteMatchHelperFactory implements FactoryInterface
{
    /**
     * @param  ServiceLocatorInterface $serviceLocator
     * @return RouteMatchHelper
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $serviceManager = $serviceLocator->getServiceLocator();
        /** @var RouteMatch $routeMatch */
        $routeMatch = $serviceManager->get('Application')->getMvcEvent()->getRouteMatch();
        return new RouteMatchHelper($routeMatch);
    }
}

参考:http://blogs.msdn.com/b/amar/archive/2014/05/12/status-bar-in-windows-phone-8-1.aspx

对于WP Silverlight App: 您可能需要在标签

下的App.xaml中定义样式
     var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
     statusBar.BackgroundColor = Colors.Green;
     statusBar.ForegroundColor = Colors.Red;
     statusBar.BackgroundOpacity = 1;

     statusBar.ProgressIndicator.Text = "Some text";
     statusBar.ProgressIndicator.ShowAsync();

在单个xaml页面上,您可以添加此样式

 <Style x:Key="SystemTrayStyle" TargetType="phone:PhoneApplicationPage">
        <Setter Property="shell:SystemTray.BackgroundColor" Value="Red" />
        <Setter Property="shell:SystemTray.ForegroundColor" Value="Green" />
    </Style>