WPF 样式和资源 给某个元素设置Style样式
来源:互联网 发布:安卓改iphone6在线软件 编辑:程序博客网 时间:2024/04/30 09:35
一、简单实例。文件分布。
二、Style文件类型是这样的
三、WPF View页面(MainWindow.xaml)
需要写这代码;
<Window x:Class="WPFiveStar.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Style/Style.xaml"/> //红色字体是实现重点
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Button Content="Click me" x:Name="Button_key" Width="150" Height="50" Style="{StaticResource Button_key}"/>
</Grid>
</Window>
四、Style页面
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="Button_key" TargetType="Button">
<Setter Property="Background" Value="Red"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</ResourceDictionary>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="Button_key" TargetType="Button">
<Setter Property="Background" Value="Red"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="14"/>
</Style>
</ResourceDictionary>
0 0
- WPF 样式和资源 给某个元素设置Style样式
- WPF 样式和资源
- WPF 之 样式 Style
- 样式<style>资源
- 样式资源(style)和主题的使用
- WPF中的Style(风格,样式)
- WPF中的Style(风格,样式)
- WPF中的Style(风格,样式)
- WPF中的Style(风格,样式)
- WPF 中的样式(Style)
- WPF style 样式的使用
- WPF样式(Style)入门
- js 设置 style 样式
- 给元素标签设置样式方法
- android style(样式)和theme(主题)设置
- android style(样式)和theme(主题)设置
- android style(样式)和theme(主题)设置
- Android style(样式)和theme(主题)设置
- 关于js中 json对象和json字符串的总结
- 数组的基本操作
- spring 基于Aspect和注解的切面编程(aop)
- 【Java基础】——HTML隐藏域
- UILabel属性
- WPF 样式和资源 给某个元素设置Style样式
- 第十四周项目1线性表的折半查找(递归法)
- NSBundle
- lua学习 lua,c++对象调用流程
- 远程控制桌面,外网电脑PC手机ios安卓mac远程桌面连接内网linux和windows主机,史上最全最详细图文教程
- iOS懒加载
- 黑马程序员-c语言回顾-进制
- [Javascript Data Structures] LinkedList 链表
- POJ 3070 Fibonacci 矩阵乘法