<tfoot id='RVUYX'></tfoot>

<small id='RVUYX'></small><noframes id='RVUYX'>

  • <i id='RVUYX'><tr id='RVUYX'><dt id='RVUYX'><q id='RVUYX'><span id='RVUYX'><b id='RVUYX'><form id='RVUYX'><ins id='RVUYX'></ins><ul id='RVUYX'></ul><sub id='RVUYX'></sub></form><legend id='RVUYX'></legend><bdo id='RVUYX'><pre id='RVUYX'><center id='RVUYX'></center></pre></bdo></b><th id='RVUYX'></th></span></q></dt></tr></i><div id='RVUYX'><tfoot id='RVUYX'></tfoot><dl id='RVUYX'><fieldset id='RVUYX'></fieldset></dl></div>
      <bdo id='RVUYX'></bdo><ul id='RVUYX'></ul>

        <legend id='RVUYX'><style id='RVUYX'><dir id='RVUYX'><q id='RVUYX'></q></dir></style></legend>

        以编程方式更改 Windows 10 UWP 应用程序中的主题

        时间:2023-09-15
        • <bdo id='NlM0I'></bdo><ul id='NlM0I'></ul>
            <tbody id='NlM0I'></tbody>

              • <tfoot id='NlM0I'></tfoot><legend id='NlM0I'><style id='NlM0I'><dir id='NlM0I'><q id='NlM0I'></q></dir></style></legend>
                • <i id='NlM0I'><tr id='NlM0I'><dt id='NlM0I'><q id='NlM0I'><span id='NlM0I'><b id='NlM0I'><form id='NlM0I'><ins id='NlM0I'></ins><ul id='NlM0I'></ul><sub id='NlM0I'></sub></form><legend id='NlM0I'></legend><bdo id='NlM0I'><pre id='NlM0I'><center id='NlM0I'></center></pre></bdo></b><th id='NlM0I'></th></span></q></dt></tr></i><div id='NlM0I'><tfoot id='NlM0I'></tfoot><dl id='NlM0I'><fieldset id='NlM0I'></fieldset></dl></div>

                  <small id='NlM0I'></small><noframes id='NlM0I'>

                  本文介绍了以编程方式更改 Windows 10 UWP 应用程序中的主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我可以使用 this.RequestedTheme = ElementTheme.Dark; 更改主题但是我需要的是整个应用程序级别,因为这只是将当前页面的主题更改为黑暗.

                  I was able to change theme using this.RequestedTheme = ElementTheme.Dark; But what I need is the whole application level, since this one only change the theme of the current page to dark.

                  每当我尝试这个 App.Current.RequestedTheme = ApplicationTheme.Dark;我总是收到这个错误

                  Whenever I try this App.Current.RequestedTheme = ApplicationTheme.Dark; I always get this error

                  UWPApp.exe 中出现System.NotSupportedException"类型的异常,但未在用户代码中处理

                  An exception of type 'System.NotSupportedException' occurred in UWPApp.exe but was not handled in user code

                  有没有一种方法可以将整个应用程序主题从浅色更改为深色,反之亦然?

                  Is there such a way that I can change the whole application theme from Light to Dark or vice versa?

                  我正在使用 VS2015

                  I'm using VS2015

                  推荐答案

                  更新了我最终决定的答案.

                  我使用了一个设置类,其中包含所有应用设置,包括要使用的主题.由于主题只能在启动时设置,我们需要确保设置它们.这是我使用的代码:

                  I used a settings class that holds all of the apps settings including what theme to use. Since the theme can only be set when it starts we need to make sure to set it them. This is the code I used:

                  在 App.xaml.cs 文件中:

                  In the App.xaml.cs file:

                  public App()
                  {
                      //Load settings
                      AppSettings.LoadSettings();
                      this.RequestedTheme = AppSettings.SelectedTheme;
                  
                      this.InitializeComponent();
                  }
                  

                  确保在 App.xaml 文件中删除此属性:

                  In the App.xaml file make sure to remove this property:

                      RequestedTheme="Light"
                  

                  如果它没有被移除,它总是默认点亮,无法改变它.

                  If its not removed it always default to light with no way to change it.

                  这样用户可以选择主题,它会在应用启动时被存储和使用.只需确保在应用初始化阶段加载并应用它即可.

                  This way the user can choose the theme, it gets stored and used when the app starts. Just make sure to load it and apply it in the app initialization phase.

                  这篇关于以编程方式更改 Windows 10 UWP 应用程序中的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将 Windows Phone 10 应用程序部署到设备上? 下一篇:导航页面时是否所有 UWP 应用都会泄漏内存?

                  相关文章

                  <i id='lNKcF'><tr id='lNKcF'><dt id='lNKcF'><q id='lNKcF'><span id='lNKcF'><b id='lNKcF'><form id='lNKcF'><ins id='lNKcF'></ins><ul id='lNKcF'></ul><sub id='lNKcF'></sub></form><legend id='lNKcF'></legend><bdo id='lNKcF'><pre id='lNKcF'><center id='lNKcF'></center></pre></bdo></b><th id='lNKcF'></th></span></q></dt></tr></i><div id='lNKcF'><tfoot id='lNKcF'></tfoot><dl id='lNKcF'><fieldset id='lNKcF'></fieldset></dl></div>
                  • <bdo id='lNKcF'></bdo><ul id='lNKcF'></ul>
                • <legend id='lNKcF'><style id='lNKcF'><dir id='lNKcF'><q id='lNKcF'></q></dir></style></legend>

                  1. <tfoot id='lNKcF'></tfoot>
                  2. <small id='lNKcF'></small><noframes id='lNKcF'>