Как программно изменить тему (например, от Dark to Light) моего приложения? Я думаю, что могу переопределить системный ресурс.Windows 10 UAP change theme theme
1
A
ответ
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"
Смежные вопросы
- 1. Vaadin change Theme
- 2. Change actionbar spinner theme
- 3. Spring Boot & Theme Change
- 4. jqgrid. change theme
- 5. Atom: Markdown change theme
- 6. JQuery change theme
- 7. Custom Windows 10 Universal App Theme
- 8. Android Change Theme Inside App
- 9. Symfony 3 change label theme
- 10. Sugar CRM theme wont change
- 11. Windows7 RSS Theme Theme
- 12. Windows 7 Aero theme
- 13. PyWin32: Windows Classic theme
- 14. Word Theme Child Theme Path
- 15. Отсутствует аргумент 1 для Teepluss \ Theme \ Theme :: Teepluss \ Theme \ {закрытие}()
- 16. Android change theme on result activity
- 17. WooCommerce Flatsome theme change product image size
- 18. Change Dialog Theme для каждого диалога
- 19. MS Access 2010 Change Theme Through VBA
- 20. WordPress woocommerce plugin change theme layout
- 21. Divi Wordpress Theme - Change Slide speed speed
- 22. Android Studio: Theme Change - Empty Activity
- 23. Windows 10 UAP back button
- 24. Windows 10 получить UAP-версию
- 25. ExtendedExecutionSession в Windows 10 UAP
- 26. Interaction.Behaviors в Windows 10 UAP
- 27. Windows 10 UAP - Application.Suspending event
- 28. Altering RStudio Editor Theme
- 29. Android Black Theme vs White Theme
- 30. Wordpress Child Theme Override Parent Theme Class