本文摘自PHP中文网,作者一个新手,侵删。
1.隐式方法,通过仅指定 Style 的 TargetType。(设置全部的Button样式)
1 2 3 4 5 6 | 1 <Page.Resources >
2 <Style TargetType= "Button" >
3 <Setter Property= "BorderBrush" Value= "Lime" />
4 <Setter Property= "BorderThickness" Value= "4" />
5 </Style>
6 </Page.Resources>
|
2.显式方法,通过指定 Style 的 TargetType 和 x:Key 特性这一特性,然后通过使用显式键的 {StaticResource} 标记扩展引用设置目标控件的 Style 属性
1 2 3 4 5 6 7 8 9 | <Page.Resources >
<Style x:Key= "btnStyle" TargetType= "Button" >
<Setter Property= "BorderBrush" Value= "Lime" />
<Setter Property= "BorderThickness" Value= "4" />
</Style>
</Page.Resources>
<Button Content= "跳转方法" x:Name= "btnTest" Style= "{StaticResource btnStyle}" />
|
3.单个样式表示
1 2 3 4 5 6 7 8 9 10 | <Application.Resources>
<SolidColorBrush x:Key= "BlueBrush" Color= "#FF1C90D1" />
</Application.Resources>
<Rectangle Height= "2" Width= "18" Fill= "{StaticResource EggshellBrush}" />
App.Current.Resources[ "EggshellBrush" ] as SolidColorBrush
|
4.使用样式文件进行调整样式
阅读剩余部分
相关阅读 >>
c# 中guid生成格式有哪些方法
uwp中设置控件样式四种方法
memorycache问题修复的解决方法
c#中关于扩展方法的实例分析
使用一个wpf程序起调一个uwp程序
克隆对象的方法实例教程
有关.net mvc长轮询的实现方法
task用法之启动方法实例
.net winform的gdi双缓冲的实现方法_实用技巧
分享html元素调用服务器实例
更多相关阅读请进入《方法》频道 >>
清华大学出版社
作者:[美]克里斯琴·内格尔(Christian Nagel)著。出版时间:2019年3月。
转载请注明出处:木庄网络博客 » UWP中设置控件样式四种方法