自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

WPF更新數(shù)據(jù)源相關(guān)操作指南

開發(fā) 開發(fā)工具
當(dāng)我們開始進(jìn)行WPF更新數(shù)據(jù)源的操作時(shí),首先需要讓對(duì)象實(shí)現(xiàn)INotifyPropertyChanged接口,最后還需要設(shè)置更新數(shù)據(jù)源執(zhí)行時(shí)間。

WPF數(shù)據(jù)源的操作對(duì)于一個(gè)初學(xué)者來說可能還不能很好的把握其要領(lǐng)。我們?cè)谶@里就為大家介紹一下有關(guān)WPF更新數(shù)據(jù)源的相關(guān)介紹。#t#

WPF更新數(shù)據(jù)源1.讓對(duì)象實(shí)現(xiàn)INotifyPropertyChanged接口,以便屬性更改發(fā)出通知

 

  1. public class Person : 
    INotifyPropertyChanged  
  2. {  
  3. public Person() { }  
  4. public Person(string 
    name, int age)  
  5. {  
  6. this.name = name;  
  7. this.age = age;  
  8. }  
  9. string name;  
  10. public string Name  
  11. {  
  12. get { return this.name; }  
  13. set  
  14. {  
  15. this.name = value;  
  16. OnPropertyChanged("Name");  
  17. }  
  18. }  
  19. int age;  
  20. public int Age  
  21. {  
  22. get { return this.age; }  
  23. set  
  24. {  
  25. this.age = value;  
  26. OnPropertyChanged("Age");  
  27. }  
  28. }  
  29. public event PropertyChanged
    EventHandler PropertyChanged;  
  30. protected void OnProperty
    Changed(string propName)  
  31. {  
  32. if (this.PropertyChanged != null)  
  33. {  
  34. PropertyChanged(this, new 
    PropertyChangedEventArgs(propName));  
  35. }  
  36. }  

WPF更新數(shù)據(jù)源2.xaml(略去布局)

  1. < Label Content=
    "{Binding Name}">< /Label> 
  2. < Label Content=
    "{Binding Age}">< /Label> 
  3. < TextBox Text="{Binding 
    Path=Name, Source={Static
    Resource Tom}}"
     /> 
  4. < TextBox Text="
    {Binding Age}"
       
  5. /> 

這里又出現(xiàn)了新的綁定語法,{Binding Path=Age}等價(jià){Binding Age}

WPF更新數(shù)據(jù)源3.目標(biāo):

當(dāng)更改目標(biāo)屬性的時(shí)候,更新數(shù)據(jù)源(更新以后則綁定的對(duì)象也發(fā)生變化,如更改TextBox的Text則Label的Content也發(fā)生變化)

WPF更新數(shù)據(jù)源4.設(shè)置更新數(shù)據(jù)源執(zhí)行時(shí)間

通過設(shè)置Binding對(duì)象的UpdateSourceTrigger 來確定執(zhí)行時(shí)間.

根據(jù)需要設(shè)置UpdateSourceTrigger 屬性

責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2009-12-28 14:04:06

WPF指定數(shù)據(jù)源

2009-11-03 14:56:36

ADO.NET數(shù)據(jù)源

2009-12-24 16:09:42

ADO.NET數(shù)據(jù)源

2009-12-31 14:23:33

ADO.NET數(shù)據(jù)源

2010-12-27 09:59:11

ODBC數(shù)據(jù)源

2009-06-15 13:24:46

JBoss數(shù)據(jù)源

2009-12-29 14:36:55

ADO.NET 數(shù)據(jù)集

2017-09-04 14:52:51

Tomcat線程數(shù)據(jù)源

2023-11-27 09:16:53

Python數(shù)據(jù)源類型

2010-06-04 10:31:05

tomcat MySQ

2009-12-31 16:38:19

Silverlight

2009-12-30 10:44:38

Silverlight

2017-06-14 23:42:27

大數(shù)據(jù)數(shù)據(jù)源架構(gòu)

2009-12-28 17:48:01

WPF界面布局

2009-09-08 11:09:39

LINQ數(shù)據(jù)源

2024-10-30 10:22:17

2009-09-15 17:15:33

Linq排序

2009-12-24 11:15:59

WPF數(shù)據(jù)綁定

2009-12-30 17:29:53

Silverlight

2009-07-21 17:41:58

JDBC數(shù)據(jù)源
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)