1、内联样式
<TextBlock FontSize="20" Foreground="Blue">好啊</TextBlock>

2、页面样式
<Button Height="20" Margin="0,78,445,213>按钮1</Button>
<Button Width="50" Height="20" Margin="0,116,453,175">按钮2</Button>

<Window.Resources>
<Style TargetType="Button" x:Key="MyStyle">
<Setter Property="Foreground" Value="Blue"></Setter>
<Setter Property="FontSize" Value="30"></Setter>
</Style>
</Window.Resources>

应用特性名称样式:
在样式中添加x:key属性
<Style TargetType="Button" x:Key="MyStyle">
<Setter Property="Foreground" Value="BlanchedAlmond"></Setter>
<Setter Property="FontSize" Value="30"></Setter>
</Style>

然后应用该样式 <Button Height="20" Margin="0,78,445,213" Style="{StaticResource MyStyle}">按钮1</Button>

3、全局样式
在App.xaml中添加
<Application.Resources>
<Style TargetType="Button" x:Key="MyStyle">
<Setter Property="Foreground" Value="Blue"></Setter>
<Setter Property="FontSize" Value="30"></Setter>
</Style>
</Application.Resources>

4、外部样式
新建Dictionary1.xaml文件
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button" x:Key="MyStyle">
<Setter Property="Foreground" Value="Blue"></Setter>
<Setter Property="FontSize" Value="30"></Setter>
</Style>
</ResourceDictionary>

在引用页面添加
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary1.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>

WPF 四种样式的更多相关文章

  1. UITableViewCellStyle 四种样式

    四种样式如下:

  2. WPF 四种尺寸单位

    原文:WPF 四种尺寸单位 像素 px 默认单位可以省略 厘米cm 英寸 in 点 pt 1in = 96px 1cm=96/2.42px 1pt=96/72px

  3. CSS 四种样式表 六种规则选择器 五种常用样式属性

    新的html程序要在VS中编写了,在vs中安装ASP.NET和Web开发,并用ASP.NET Web 应用程序(.NETFramework)创建一个网页程序.添加一个html页 后面的代码都是在htm ...

  4. CSS的四种样式

    行内式CSS样式 在标签内部使用的样式 <div id="one" style="width:50p"></div> 内嵌式CSS样式 ...

  5. Css四种样式

    1. 2 3 4 5 6.

  6. a 标签的四种样式

    在支持 CSS 的浏览器中,链接的不同状态都可以不同的方式显示,这些状态包括:活动状态,已被访问状态,未被访问状态,和鼠标悬停状态.分别如下设置: a:link {color: red} /* 未访问 ...

  7. Python中四种样式的99乘法表

    1.常规型. #常规型 i=1 while i<=9: j=1 while j<=i: print(''%d*%d=%2d''%(i,j,i*j),end='') i+=1 #等号只是用来 ...

  8. HTML5样式和列表、CSS链接的四种状态

    一.HTML5样式 1.标签: <style>:样式定义: <link>:资源引用: 2.属性: type="text/css":引入文档类型: rel=& ...

  9. CSS02--四种样式、背景、文本、链接状态、表格样式

    接上面的“CSS01”,我们接着来说一下样式.很多人不知道的是一个HTML元素有四种样式,分别是浏览器默认样式.外部样式.内部样式.内联样式,而它们的优先级是越来越高的,后面的样式会覆盖前面的样式.多 ...

随机推荐

  1. rpm---linux软件安装与管理

    linux的安装命令选项太多,整理一下,方便后期查找. 汇总: install: rpm -ivh 包全名 安装 upgrade: rpm -Uvh 包全名 升级 erase: rpm -e 包名 删 ...

  2. windows7下修改hosts文件无效解决办法(转)

    通常会为了开发方便.或者屏蔽掉一些恶意网站,我们会在hosts(c:\windows\system32\drivers\etc\hosts)文件中进行相应的域名指向,例:

  3. Spring BeanNameAutoProxyCreator 与 ProxyFactoryBean区别

    一般我们可以使用ProxyBeanFactory,并配置proxyInterfaces,target和interceptorNames实现,但如果需要代理的bean很多,无疑会对spring配置文件的 ...

  4. Androidstudio报错UnsupportedClassVersionError

    报错信息 Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.m ...

  5. PHP cookie

    PHP Cookie cookie 常用于识别用户. Cookie 是什么? cookie 常用于识别用户.cookie 是一种服务器留在用户计算机上的小文件.每当同一台计算机通过浏览器请求页面时,这 ...

  6. [Machine Learning] Learning to rank算法简介

    声明:以下内容根据潘的博客和crackcell's dustbin进行整理,尊重原著,向两位作者致谢! 1 现有的排序模型 排序(Ranking)一直是信息检索的核心研究问题,有大量的成熟的方法,主要 ...

  7. How to generate UML Diagrams from Java code in Eclipse

    UML diagrams compliment inline documentation ( javadoc ) and allow to better explore / understand a ...

  8. html页面的CSS、DIV命名规则

    CSS命名规则 头:header 内容:content/containe 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrapper 左右中:l ...

  9. BZOJ2982——combination

    1.题意:求 C(n,m) % 10007 ,10007是质数咯 n和m < 2000000000 2.分析:这个东西太大了,显然不能用n!的阶乘预处理的方式搞出来,也不能用递推公式搞出来 于是 ...

  10. jquery 赋值文本框输入框

    jQuery("#mrId option[value='" + extValue + "']").attr("selected", true ...