3

Windows 8 Store アプリケーションの既定の背景色を定義しようとしていますが、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

これらの 2 つのブラシは、StandardStyles.xaml のいくつかのスタイルでのみ使用されているようです。そのうちの 1 つは

<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 に答える