元素绑定

基本格式:

FontSize="{Binding ElementName=Slider,Path=Value,Mode=TwoWay}"

等价于:

Binding binding = new Binding();
binding.Source = this.Slider;
binding.Path = new PropertyPath("Value");
binding.Mode = BindingMode.TwoWay;
this.TextBlock1.SetBinding(TextBlock.FontSizeProperty, binding);

 

绑定模式 Mode:

  • OneWay : 源改变目标改变,目标改变不影响源
  • OneTime:最初根据源改变目标,以后更改源,也不更改目标
  • TwoWay:双向绑定
  • OneWayToSource:目标改变,更新源,但只更新最初的一次
  • Default :依赖目标属性

绑定更新: UpdateSourceTrigger=PropertyChanged

posted @ 2021-12-12 21:50  白清欢  阅读(39)  评论(0编辑  收藏  举报