WP7备注(30)(数据绑定基本)
2011-05-03 11:36 血糯米Otomii 阅读(312) 评论(0) 编辑 收藏 举报基础模式:
<TextBlock … Text="{Binding ElementName=slider, Path=Value, Mode=TwoWay}" … />
树结构元素赋值:
Text="{Binding ElementName=ContentPanel, Path=Children[0].Value}"
Text="{Binding ElementName=LayoutRoot, Path=Children[1].Children[0].Value}"
代码绑定:
Binding binding = new Binding(); binding.ElementName = "slider"; binding.Path = new PropertyPath("Value"); txtblk.SetBinding(TextBlock.TextProperty, binding);