Web- und Software Development

Wie finde ich das vom Benutzer aktuell gewählte Theme heraus? – WP7 Quicky

Written By: - Nov• 09•10

Antwort: Das Windows Phone 7 bietet zwei Basis-Themes, dark und light. Um als Entwickler heraus zu finden, welches der Benutzer gewählt hat, kann man folgenden Ansatz verwenden:

Die App.cs um folgenden Code erweitern:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private static SolidColorBrush backgroundBrush;
internal static Theme CurrentTheme
{
    get
    {
        if (backgroundBrush.IsNull())
            backgroundBrush = Application.Current.Resources["PhoneBackgroundBrush"] as SolidColorBrush;
 
        return backgroundBrush.Color == Color.FromArgb(255, 255, 255, 255) ?
            Theme.Light : Theme.Dark;
    }
}
public enum Theme
{
    Dark = 0,
    Light = 1
}

Verwendungsbeispiel:

if (App.CurrentTheme == App.Theme.Light)
//your code

Demnächst jeden Tag ein Windows Phone 7 Quicky. Also bleib dran!

Viel Spaß beim entwickeln : )

Ähnliche Beiträge

You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.