【问题标题】:UWP NavigationView header not changing with themeUWP NavigationView 标题不随主题而变化
【发布时间】:2021-04-30 11:24:18
【问题描述】:

更改 RequestedTheme 时,NavigationView 的标题背景不会更新。 尝试使用 headertemplate,但没有解决任何问题。 窗口标题栏也有同样的问题。

切换前:

切换后:

我的主题切换代码:

    public class AppThemeService : IAppThemeService
    {
        public void ApplyTheme(ApplicationTheme? theme)
        {
            var elementTheme = theme.ToElementTheme();
            if (Window.Current.Content is FrameworkElement element)
                element.RequestedTheme = elementTheme;
        }
    }

有人知道解决办法吗?

谢谢。

【问题讨论】:

    标签: uwp navigationview


    【解决方案1】:

    通过在其上放置背景找到了导航视图的解决方案:

    <NavigationView x:Name="navigationView" Background="{ThemeResource SystemAltHighColor}">
    

    还没有找到适合标题栏的东西。 尝试在主题更改时从 App.Resources 的代码中获取 SystemAltHighColor,以便我可以在标题栏上设置它。但这给了我相同的颜色,如果应用程序以暗模式启动,则为黑色。

    【讨论】:

    • 如果您已经解决了您的问题,请mark它被接受
    猜你喜欢
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 2015-03-27
    • 2021-11-18
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 2019-01-31
    相关资源
    最近更新 更多