开发者

Windows Phone - Styles.xaml + Mango Conversion

I had an application build with the Windows Phone 7.0 SDK. I now need to update that application to the Windows Phone 7.1 SDK. When I migrated the application, the background of all of my pages were changed to black. However, they were all White (as intended) when I used the 7.0 SDK. How do I fix this? With the 7.0 SDK all of my pages were defined as:

<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}">
...
</Grid>

The PhoneBackgroundBrush is defined in Styles.xaml. This file has the following:

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:System="clr-namespace:System;assembly=mscorlib">
  <Color x:Key="PhoneBackgroundColor">#FFFFFFFF</Color>
  <SolidColorBrush x:Key="PhoneBackgroundBrush" Color="{StaticResource PhoneBackgroundColor}"/>
  </ResourceDictionary>

Styles.xaml is referenced in App.xaml as shown here:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
           开发者_如何学Python <ResourceDictionary Source="Resources/Styles.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

What is wrong? How do I get my background back to being White?


See this article: Overriding themes in Windows Phone 7.5 (Mango) (Scroll down for the Mango parts)

In short: You can't override the inherited XAML styles anymore. You have to override them in C# code, such as

(App.Current.Resources["PhoneBackgroundBrush"] as SolidColorBrush).Color = Colors.White;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜