我想在windows-8中用我自己的RGB值创建新的颜色。
就像安卓里的color.xml一样。
有人知道怎么做吗?
发布于 2012-10-15 15:43:55
我创建了一个Color.xaml资源字典,如下所示
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="MyBlack" Color="#000000"/>
</ResourceDictionary>然后在App.xaml中,我添加了以下内容
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
...
...
<ResourceDictionary Source="Color.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>在我的Text.xaml中,我使用了这个
<TextBlock Text="How are you?" Foreground="{StaticResource MyBlack}"/>P.S.感谢Antonio Bakula的answer,请也看看这个。
发布于 2012-10-15 14:58:03
像这样定义颜色:
<Page.Resources>
<ResourceDictionary>
<SolidColorBrush x:Key="MyCustomColor">#FFDEDEDE</SolidColorBrush>
</ResourceDictionary>
</Page.Resources>像这样使用它:
<TextBlock Text="Test" Foreground="{StaticResource MyCustomColor}"></TextBlock>如果您想定义自定义应用程序样式,请查看以下内容:
http://www.markermetro.com/2012/07/technical/windows-8-overriding-metro-app-resources/
https://stackoverflow.com/questions/12890172
复制相似问题