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

在開發(fā)應(yīng)用中WPF優(yōu)點(diǎn)的體現(xiàn)

開發(fā) 開發(fā)工具
WPF優(yōu)點(diǎn)包括:擁有讓控件更靈活的Data Template ;具有比Windows Forms更強(qiáng)的Binding ;可以讓排版更靈活的各種Layout控件等。

WPF為什么會被開發(fā)人員如此重視,在開發(fā)過程中又為何會占據(jù)著重要的地位呢?這就要先從WPF優(yōu)點(diǎn)來分析。我們將會為大家總結(jié)出幾個WPF優(yōu)點(diǎn)方便大家理解。#t#

WPF優(yōu)點(diǎn)之讓控件更靈活的Data Template

C#代碼

  1. GridViewColumn gvcName = 
    new GridViewColumn();   
  2. gvcName.Header = "Name";   
  3. DataTemplate nameTemplate = 
    new DataTemplate();   
  4. FrameworkElementFactory 
    nameFactory = new Framework
    ElementFactory(typeof(Contact
    PropertyLabel));   
  5. Binding binding = new 
    Binding("Name");   
  6. binding.Mode = BindingMode.TwoWay;   
  7. nameFactory.SetBinding
    (ContentProperty, binding);   
  8. nameTemplate.VisualTree = 
    nameFactory;   
  9. gvcName.CellTemplate = 
    nameTemplate;   
  10. gvContactList.Columns.Add(gvcName);   
  11. GridViewColumn gvcName = 
    new GridViewColumn();  
  12. gvcName.Header = "Name";  
  13. DataTemplate nameTemplate = 
    new DataTemplate();  
  14. FrameworkElementFactory nameFactory = 
    new FrameworkElementFactory
    (typeof(ContactPropertyLabel));  
  15. Binding binding = new Binding("Name");  
  16. binding.Mode = BindingMode.TwoWay;  
  17. nameFactory.SetBinding
    (ContentProperty, binding);  
  18. nameTemplate.VisualTree = nameFactory;  
  19. gvcName.CellTemplate = nameTemplate;  
  20. gvContactList.Columns.Add(gvcName); 

 

這段代碼可以給一個ListView的一列做雙向綁定,并且指定這一行的渲染控件。

WPF優(yōu)點(diǎn)之比Windows Forms更強(qiáng)的Binding

C#代碼

  1. public class Contact : 
    DependencyObject   
  2. {   
  3. public static DependencyProperty 
    NameProperty = DependencyProperty.
    Register("Name", typeof (string), 
    typeof (Contact));   
  4. public string Name   
  5. {   
  6. get { return (string) GetValue
    (NameProperty); }   
  7. set { SetValue(NameProperty, value); }   
  8. }   
  9. }   
  10. public class Contact : DependencyObject  
  11. {  
  12. public static DependencyProperty 
    NameProperty = DependencyProperty.
    Register("Name", typeof (string), 
    typeof (Contact));  
  13. public string Name  
  14. {  
  15. get { return (string) GetValue
    (NameProperty); }  
  16. set { SetValue(NameProperty, 
    value); }  
  17. }  

 

DependencyObject + DependencyProperty使得屬性設(shè)置可以自動觸發(fā)ValueChanged事件,從而讓Binding進(jìn)行更新。

WPF優(yōu)點(diǎn)之讓排版更靈活的各種Layout控件

對于普通界面的排版,用Grid+Border

對于要動態(tài)添加刪除的界面排版,在需要動態(tài)增刪的位置使用StackPanel

責(zé)任編輯:曹凱 來源: javaeye.com
相關(guān)推薦

2009-12-29 14:00:02

WPF Dispatc

2010-03-25 11:08:08

Python優(yōu)點(diǎn)

2009-12-24 17:52:05

WPF觸發(fā)器

2009-12-25 15:29:12

WPF缺陷

2009-12-25 16:40:49

WPF優(yōu)勢

2010-03-03 17:52:31

Python線程同步

2010-01-08 18:02:33

VB.NET事件

2010-03-04 10:35:51

Python下劃線

2010-02-25 17:22:39

WCF服務(wù)行為

2010-01-14 10:35:34

VB.NET指針

2010-02-02 13:15:00

C++ lambda函

2009-12-28 16:45:31

WPF窗體

2010-03-24 14:55:19

Python編程語言

2010-03-19 17:15:43

2009-12-28 09:50:08

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

2018-10-11 10:38:31

前端JavaScript編程語言

2010-01-15 13:30:53

VB.NET Tool

2012-08-24 09:58:09

ReactorDSSC

2010-03-29 11:17:33

Oracle Spat

2009-12-07 13:20:14

PHP技術(shù)應(yīng)用
點(diǎn)贊
收藏

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