Wpf 对象属性赋值---属性标签
2011-08-18 17:54
309 查看
1。给一个stop按钮赋予一个stop的图形。
如图:
View Code 1 <Window x:Class="wpf.Window1"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 Title="Window1" Height="300" Width="300">
5 <Grid>
6 <Rectangle Width="300" Height="200">
7 <Rectangle.Fill>
8 <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
9 <LinearGradientBrush.GradientStops>
<GradientStop Offset="0.1" Color="Yellow"/>
<GradientStop Offset="0.5" Color="blue"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Window>
原则。1,能使用attribute=value对属性赋值,尽量使用这种方式。
2,若使用默认值的属性,则可以不用写出来,
比如: <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> 默认的StartPoint为“”0,0“ 默认的EndPoint为”1,1“则可以不写出来。如下:
<LinearGradientBrush>
参考:属性标签
如图:
View Code 1 <Window x:Class="wpf.Window1"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 Title="Window1" Height="300" Width="300">
5 <Grid>
6 <Rectangle Width="300" Height="200">
7 <Rectangle.Fill>
8 <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
9 <LinearGradientBrush.GradientStops>
<GradientStop Offset="0.1" Color="Yellow"/>
<GradientStop Offset="0.5" Color="blue"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Window>
原则。1,能使用attribute=value对属性赋值,尽量使用这种方式。
2,若使用默认值的属性,则可以不用写出来,
比如: <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> 默认的StartPoint为“”0,0“ 默认的EndPoint为”1,1“则可以不写出来。如下:
<LinearGradientBrush>
参考:属性标签
相关文章推荐
- WPF 之 XAML语法,对象属性赋值(简单赋值、TypeConverter 标签属性与对象属性映射、标记扩展),引用外部库
- Wpf 使用标签扩展为对象的属性赋值。
- 无废话WPF系列3: XAML中为对象属性赋值
- WPF中XMAL对象属性赋值及属性类型转换机制
- WPF学习旅程(三)——在XAML中为对象的属性赋值
- 反射遍历对象属性并赋值
- 选中对象【WPF】自定义控件之依赖属性
- java的BeanUtils.copyProperties会把为数据源对象中数字包装对象为null的值改成0赋值给操作对象的属性
- 源码变换 超文本标记语言(即HTML),是用于描述网页文档的一种标记语言。 HTML通过文本来描述文档显示出来应该具有的“样子”。它主要通过标签来定义对象的显示属性或行为。
- php删除多重数组对象属性,重新赋值的方法
- 对象属性之间的相互赋值
- ruby范例3:对象,方法调用,属性赋值
- 微信小程序 两种为对象属性赋值的方式详解
- XAML属性赋值转换之谜(WPF XAML语法解密)
- JS中undefined、null以及NaN之间的区别,以及对象属性赋值的面试题
- DozerBeanMapper对象之间相同属性名赋值
- jQuery选择器ID、CLASS、标签获取对象值、属性、设置css样式
- [JQuery] jQuery选择器ID、CLASS、标签获取对象值、属性、设置css样式
- 创建javaScript自定义对象,并给属性赋值
- java对象之间相同属性名赋值