windows8商店应用程序开发数据绑定

来源:互联网 发布:雅思高分知乎 编辑:程序博客网 时间:2024/04/28 08:19
1. Binding
<targetObject targetProperty="{Binding}" ...> ... </targetObject>

 <targetObject targetProperty="{Binding [Path=]bindingSourceProperty}" ...> ... </
targetObject>


2. StaticResource
<object propertyName="{StaticResource resourceKey}" ...> ... </ object>
 resourceKey 是被引用的资源的键,由资源定义时的 x:Key 或 x:Name 指定


3. TemplateBinding
 <templateObject templateProperty="{TemplateBinding [Property=] sourceObjectProperty}" 
...> ... </templateObject>


templateObject 是 模 板 对 象 ;templateProperty 是 模 板 对 象 的 属 性 ;Property
是 TemplateBinding 的 属 性, 用 于 指 定 被 绑 定 对 象 的 属 性, 通 常 可 省 略 不 写 ;
sourceObjectProperty 是被绑定对象的属性。


4. RelativeSource
 TemplatedParent 模式通常使用于 ControlTemplate 元素定义中
 <object property="{Binding RelativeSource={RelativeSource [Mode=]modeValue}}" ...> 
... </object>

 <object property="{Binding RelativeSource={RelativeSource [Mode=]
modeValue},[Path=]bindedProperty}" ...> ... </object>
Mode 是 RelativeSource 的属性,用于设置绑定模式,属性值有 Self
和 TemplatedParent。当 Mode 属性取值为 Self 时,表示元素或元素的属性是绑定源;取值为
TemplatedParent 时,表示引用 ControlTemplate 模板的元素或元素的属性是绑定源。Path 也
是 RelativeSource 的属性,用于指定被绑定的属性
0 0
原创粉丝点击