刚刚发现的 xaml里面颜色的定义方式

例如  <Rectangle Height="46" Stroke="Black" Fill="sc# 1,0.5,0.8,0.6"  Width="200" />

其中,sc# 为关键字,scA,scR,scG,scB为介于0.0~1.0的Single值。

第一个参数1 透明度

第二个参数0.5 红色的比例,最小0,最大1

第三个参数0.8 绿色的比例,最小0,最大1

第四个参数1 蓝色的比例,最小0,最大1

其实只是把之前的十六进制表示,换成为小数表示。

各位,可以用下面的源码试试看

 

  
1 < Window x:Class ="ColorNumber.MainWindow"
2 xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
4 Title ="MainWindow" Height ="350" Width ="525" >
5 < StackPanel Background ="Black" >
6 <!-- 四位数字依次表示如下 -->
7 <!-- 透明度 最大值1 -->
8 <!-- 红色比例 最大值1 -->
9 <!-- 蓝色比例 最大值1 -->
10 <!-- 黑色比例 最大值1 -->
11
12 <!-- 纯白 -->
13 < Rectangle Height ="46" Stroke ="Black" Fill ="sc# 1,1,1,1" Width ="200" />
14 <!-- 白色 0.5透明度 -->
15 < Rectangle Height ="46" Stroke ="Black" Fill ="sc# 0.5,1,1,1" Width ="200" />
16
17 <!-- 纯蓝色 -->
18 < Rectangle Height ="46" Stroke ="Black" Fill ="sc# 1,0,0,1" Width ="200" />
19 <!-- 纯绿色 -->
20 < Rectangle Height ="46" Stroke ="Black" Fill ="sc# 1,0,1,0" Width ="200" />
21 <!-- 纯红色 -->
22 < Rectangle Height ="46" Stroke ="Black" Fill ="sc# 1,1,0,0" Width ="200" />
23
24 <!-- 自定义的颜色 -->
25 < Rectangle Height ="46" Stroke ="Black" Fill ="sc# 1,0,0.6196078431372549,0.8156862745098039" Width ="200" />
26
27 </ StackPanel >
28   </ Window >
29  

 

 

 详细的颜色定义参考这个文章
GDI 与WPF中的颜色简析

 http://dotnet.e800.com.cn/articles/2009/224/1235455806895_1.html

MSDN:http://msdn.microsoft.com/zh-cn/library/bb980062(VS.95).aspx

http://msdn.microsoft.com/zh-cn/library/system.windows.media.color(VS.95).aspx

你可能感兴趣的:(a)