Get Variations of Accent color in UWP

别说谁变了你拦得住时间么 提交于 2019-12-22 06:57:10

问题


I'm trying to get a lighter variation of accent color using theme resource SystemAccentColorLight1 SystemAccentColorLight2 ...

I'm getting this exception: The text associated with this error code could not be found.

Cannot find a Resource with the Name/Key SystemAccentColorLight1 [Line: 15 Position: 19]

<Grid Background="{ThemeResource ResourceKey= SystemAccentColorLight1}"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="60" />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Image Source="{Binding Path=Owner.ProfileImage}" Width="50" Height="50" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"></Image>
            <TextBlock Text="{Binding Title}" FontSize="12" TextWrapping="WrapWholeWords" FontWeight="SemiBold" Grid.Column="1" Grid.ColumnSpan="2"/>
            <TextBlock Text="{Binding Path=Owner.DisplayName}" VerticalAlignment="Bottom" HorizontalAlignment="Left" FontSize="9" Grid.Column="1" Grid.Row="1" />
        </Grid>

https://msdn.microsoft.com/windows/uwp/style/color?f=255&MSPPError=-2147217396

In XAML, the primary accent color is exposed as a theme resource named SystemAccentColor. The shades are available as SystemAccentColorLight3, SystemAccentColorLight2, SystemAccentColorLight1, SystemAccentColorDark1, SystemAccentColorDark2, and SystemAccentColorDark3. Also available programmatically via UISettings.GetColorValue and the UIColorType enum.


回答1:


As @Mark W said, the SystemAccentColorLight1 is from a newer SDK.

I test it with Window 10 Enterprise Insider Preview Edition and OS Build is 14316.1000. It can get the lighter variation of accent color.

You're welcome to join the Windows Insider Program and you can download preview SDK to use this feature.

Remarks:

Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.



来源:https://stackoverflow.com/questions/37051106/get-variations-of-accent-color-in-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!