2013-02-26 110 views
2

我想爲我的Windows 8商店應用程序定義一個默認背景顏色,但是雖然它在XAML編輯器和Blend中正確顯示,但它在Windows 8和Windows RT模擬器上運行時會出現默認的黑色背景。爲什麼重寫ApplicationPageBackgroundThemeBrush不起作用?

我基於「Split App」VS 2012模板創建了一個全新的Windows 8應用程序,並修改了App.xaml以指定ApplicationPageBackgroundThemeBrush的新值。

這是我的App.xaml是什麼樣子:

<Application 
x:Class="App3.App" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:App3" 
xmlns:localData="using:App3.Data"> 

<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 

      <!-- 
       Styles that define common aspects of the platform look and feel 
       Required by Visual Studio project and item templates 
      --> 
      <ResourceDictionary Source="Common/StandardStyles.xaml"/> 
     </ResourceDictionary.MergedDictionaries> 

     <!-- Application-specific resources --> 

     <x:String x:Key="AppName">App3</x:String> 

     <!-- Basic foreground and background colours --> 
     <SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#FF3CA5DC"/> 
     <SolidColorBrush x:Key="ApplicationPageForegroundThemeBrush" Color="White"/> 

    </ResourceDictionary> 
</Application.Resources> 

回答

4

看來,那些2個刷僅用於在StandardStyles.xaml,其中一人是幾個款式是

<Style x:Key="LayoutRootStyle" TargetType="Panel"> 

你可以應用到你的根面板。但是您對App.xaml的更改不會影響此樣式。它僅影響進一步使用這種刷的,所以如果你想使用這些特定的刷子我看到下面的變種:

1)在app.xml中聲明他們進一步使用它像:

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> 

2)聲明他們StadardStyles.xaml

<ResourceDictionary.ThemeDictionaries> 
    <ResourceDictionary x:Key="Default"> 
     <!-- Style Goes Here --> 
    </ResourceDictionary> 
</ResourceDictionary.ThemeDictionaries> 

在這種情況下,所有StandardStyles將受到影響下,但你應該在你的網格也使用LayoutRootStyle。

但是,真的,使用這些畫筆顯示如此利潤的利潤,我認爲這是更好的只是將您的面板背景設置爲您所需要的。

+0

感謝你的看起來,微軟似乎沒有讓默認模板特別有用,就像這樣,進度條默認粉紅色! – Richard 2013-03-01 09:52:52