WP7 如何让您的应用程序与手机的Theme保持一致

Application.Current.Resources集合中有许多的系统资源可以使用,例如:

 

1 得到当前手机的背景(Settings->Theme->Background).

 

Visibility darkBackgroundVisibility =
            (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];

 

2 得到当前手机的强调色(Settings->Theme->Accent colour)

Color currentAccentColorHex =
            (Color)Application.Current.Resources["PhoneAccentColor"];

 

比如说:Rectangle控件,可以直接绑定PhoneAccentColor.

<Rectangle
                Height="100"
                HorizontalAlignment="Left"
                Margin="12,33,0,0"
                Name="rectangle1"
                Stroke="{StaticResource PhoneForegroundBrush}"
                StrokeThickness="1"
                VerticalAlignment="Top"
                Width="200"
                Fill="{StaticResource
PhoneAccentBrush}" />
详细参考:How to: Apply Theme Resources for Windows Phone


posted on 2011-12-18 12:36  Stephen Ding  阅读(193)  评论(0)    收藏  举报