我正在尝试为页面中的控件定义标准前景色。但是,出现错误“类型为“ System.String”的对象无法应用于期望类型为“ Windows.UI.Xaml.Media.Brush”的属性”。

在myPage.xaml中

<TextBlock TextWrapping="Wrap"
           Foreground="{StaticResource ForegroundThemeBrush}" />


在StandardStyles.xaml中

<ResourceDictionary x:Key="Default">

  <x:String x:Key="BackgroundThemeBrush">#484848</x:String>
  <x:String x:Key="ForegroundThemeBrush">#efefef</x:String>

</ResourceDictionary>

最佳答案

您需要定义SolidColorBrush而不是x:String

<ResourceDictionary x:Key="Default">
  <SolidColorBrush x:Key="BackgroundThemeBrush" Color="#484848"/>
  <SolidColorBrush x:Key="ForegroundThemeBrush" Color="#efefef"/>
</ResourceDictionary>

关于windows-8 - winrt是否可以在资源库中定义画笔颜色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13636223/

10-12 14:04
查看更多