WP支持一个黑暗和轻的主题。用户可以将手机上的主题更改为光或暗,并且特定的属性也会相应地发生变化,如文本颜色等。
我正在尝试创建有图标图像的按钮,以自动更改以支持用户选择的主题。
有什么简单的方法吗?
下面是我做当前按钮的方式:
    <Button Name="button" Margin="250,443,86,44" VerticalAlignment="Center" Style="{StaticResource roundButton}" Height="120" Click="button_click" HorizontalAlignment="Center" Width="120">
            <Image Source="/Assets/Tiles/picture.png" HorizontalAlignment="Left" VerticalAlignment="Center" />
    </Button>发布于 2014-09-05 14:21:17
你可以做这样的事。您可以检测应用程序运行时设置的主题,并相应地更改UI元素。我正在MainPage.xaml页面中的MainPage.xaml方法中执行此操作,以更改MainPage.xaml中的元素
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    var theme = (Visibility)Resources["PhoneLightThemeVisibility"];
    if (theme == System.Windows.Visibility.Visible)
    {
        // Change the UI for Light theme
    }
    else
    {
        // Change the UI for Dark theme
    }
}尝尝这个。这应该对你有用。
https://stackoverflow.com/questions/25685832
复制相似问题