2015-10-17 4 views

ответ

1

Windows Phone 8,1, вы можете установить RequestedTheme атрибут любого контроля, или даже уровень приложения до переопределяет тему, заданную пользователями в настройках.

Пример для легкой темы:

В коде, в конструктор класса App:

/// <summary> 
/// Provides application-specific behavior to supplement the default Application class. 
/// </summary> 
public sealed partial class App : Application 
{ 
    private TransitionCollection transitions; 

    /// <summary> 
    /// Initializes the singleton application object. This is the first line of authored code 
    /// executed, and as such is the logical equivalent of main() or WinMain(). 
    /// </summary> 
    public App() 
    { 
     this.RequestedTheme = ApplicationTheme.Light; 

     this.InitializeComponent(); 
     this.Suspending += this.OnSuspending; 
    } 
} 

Или в XAML:

<Application 
    x:Class="App26.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    RequestedTheme="Light" 
    xmlns:local="using:App26"> 
</Application> 

Для Dark Theme

В коде, в конструктор класса App:

Заменить

this.RequestedTheme = ApplicationTheme.Light; 

с

this.RequestedTheme = ApplicationTheme.Dark; 

В вашем App Code или

или в XAML:

RequestedTheme="Dark" 
0

Использование RequestedThemeProperty. Вы можете изменить его с XAML или код позади для каждой страницы, управления и т.д.

Например: RequestedTheme="Light"