怎样在wp7中检测“主题背景”

由于Windows Phone 可以使用深色(黑色)或淡色(白色)主题,知道用户的主题以确定你的应用程序的颜色模式是很重要的一件事。

XAML

<Grid x:Name="LayoutRoot" Background="Transparent">
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
</Grid>

CSharp

public MainPage()
{
InitializeComponent();
Color themebackground = (Color)Application.Current.Resources["PhoneForegroundColor"];
 
if (themebackground.ToString() == "#FFFFFFFF")
{
this.PageTitle.Text = "Dark ";
}
else if (themebackground.ToString() == "#DE000000")
{
this.PageTitle.Text = "Light ";
}
}

 

原文地址:https://www.cnblogs.com/songtzu/p/2617028.html