码迷,mamicode.com
首页 > Windows程序 > 详细

wpf数据绑定的论述

时间:2014-12-25 06:35:50      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

(1)绑定模式:

<Lable x:Name=lab Content={binding UserName} /> <!--binding相当于SetBinding-->

Content={binding UserName}:理解成绑定关系,而不是赋值关系

Content={binding UserName}xaml代码等价于下面的两条语句:

Bingding bingding = new Binding("UserName"){Source=doctor} {主要包括:源 和 源的属性(即binding的path),这二者生成绑定对象}

BingdingOperations.SetBinding(lab,Lable.ContentProperty,binding[doctor、doctor.UserName]);{主要包括:绑定对象、目标和目标的依赖属性},将源(doctor)的UserName属性(binding的path)绑定到目标(lab)的ContentProperty属性(依赖属性)上。  

(2)直接赋值模式:

<Lable x:Name=lab Content="赵会东" />

public object Content

{    

    get{return GetValue(ContentProperty);}    

    set{SetValue(ContentProperty,Value);}

wpf数据绑定的论述

标签:

原文地址:http://www.cnblogs.com/changbaishan/p/4183789.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!