Windows-8 で独自の RGB 値を使用して新しい色を作成したいと考えています。
Android の color.xml と同じです。
誰もこれを行う方法を知っていますか?
2 に答える
5
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}"/>
PS Antonio Bakulaの回答に感謝します。こちらもご覧ください。
于 2012-10-15T07:43:54.597 に答える
3
このように色を定義します:
<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/
于 2012-10-15T06:58:02.843 に答える