Color
类别:
Background 背景颜色
Foreground 前景颜色(文本颜色)
测试:
<Label Content="国庆节" Background="Aqua" Foreground="Blue"/>
设置方法:
1.XAML中设置,如上
2.用画刷设置:this.T2.Background = new SolidColorBrush(Colors.Blue);
3.用系统颜色设置:this.T2.Background = System.Windows.SystemColors.ControlDarkBrush;
4.用RGB三原色设置:this.T2.Background = new SolidColorBrush(Color.FromRgb(231,42,11));
三原色,红绿蓝,整型0~255,都为0,黑色,都为255,白色
Font
- 字体大小 FontSize
- 字体粗细FontWeight
- 字体风格FontStyle(斜体……)
- 字体拉伸FontStreach
- 字型FontFamily
这是office中我们经常用到的宋体、楷体……等等,可引用ttf文件
使用方式:
1.添加ttf格式的文件到项目中
2.在XAML中某一个控件的文本FontFamily中设置如下:./# + ttf文件的名字
测试:
<Label Content="国庆节" Background="Aqua" Foreground="Blue" HorizontalAlignment="Center"
FontSize="38"
FontWeight="DemiBold"
FontStyle="Oblique"
FontStretch="Medium"
FontFamily="./#仿宋_GB2312"/>
1.GB2312,有点怀念,还在大学学生会的时候写文档专用字体格式
2.ttf有些是针对英文的、有些是针对中文的,用针对英文的格式给中文字体设置,当然会没有效果了
3.FontFamily=”./#仿宋_GB2312, ./#迷你简行楷碑, ……,……”也可以这样写,给同一个文本设置多种字体,如果有仿宋,就是仿宋,没有就是取找楷碑……
- 文本修饰TextDecorations
基本线BaseLine、上划线Overline、中划线StrikeThrough、下划线Underline……Lable中没有,用TextBlock
中划线测试:
<TextBlock Text="阅兵仪式" HorizontalAlignment="Center" FontSize="40" TextDecorations="StrikeThrough"/>
Cursor
自带的光标:
光标,给控件设置属性Cursor=”Help”,当鼠标移过去的时候光标下会附加一个?
自定义光标:
测试:
StreamResourceInfo sri = Application.GetResourceStream(new Uri("Images/pt1bar.cur", UriKind.Relative));
//加载cur文件,支持cur,不支持ani
T1.Cursor = new Cursor(sri.Stream);
当鼠标在国庆节的Lable的时候,光标变成一个转圈的流氓兔(涉及到光标截图超不方便,用手机拍照的)
案例分享:
在我整理查找的过程中,看到好的源码分享:
<Canvas>
<TextBlock FontSize="84" FontFamily="Arial Black" Margin="0,0">
<TextBlock.TextDecorations>
<TextDecoration PenOffset="10" PenOffsetUnit="Pixel" PenThicknessUnit="Pixel">
<TextDecoration.Pen>
<Pen Thickness="5">
<Pen.Brush>
<LinearGradientBrush Opacity="0.8" StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Yellow" Offset="0" />
<GradientStop Color="Red" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Pen.Brush>
<Pen.DashStyle>
<DashStyle Dashes="1,2,3"/>
</Pen.DashStyle>
</Pen>
</TextDecoration.Pen>
</TextDecoration>
</TextBlock.TextDecorations>
GOOD
</TextBlock>
</Canvas>