3

我正在尝试为我的 Windows 8 应用商店应用程序定义默认背景颜色,但尽管它在 XAML 编辑器和 Blend 中正确显示,但在 Windows 8 和 Windows RT 模拟器中运行时会出现默认的黑色背景。

我基于“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

1 回答 1

4

似乎这两个画笔只被 StandardStyles.xaml 中的几个样式使用,其中之一是

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

您可以将其应用于您的根面板。但是您在 App.xaml 中的更改不会影响此样式。它只会影响这个画笔的进一步使用,所以如果你想使用那些特定的画笔,我会看到以下变体:

1)在您的 App.xml 中声明它们并进一步使用它:

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

StadardStyles.xaml2)在下面声明它们

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

在这种情况下,所有 StandardStyles 都会受到影响,但您也应该在 Grid 中使用 LayoutRootStyle。

但实际上,使用这些画笔显示的利润太少了,我认为最好将面板背景设置为您需要的。

于 2013-02-26T16:33:26.190 回答