成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Silverlight數(shù)據(jù)綁定實(shí)現(xiàn)用戶信息

開(kāi)發(fā) 開(kāi)發(fā)工具
Silverlight數(shù)據(jù)綁定如何才能正確的操作來(lái)使它能幫助我們實(shí)現(xiàn)各種功能的需求呢?我們可以通過(guò)不斷的經(jīng)驗(yàn)積累來(lái)達(dá)到一種運(yùn)用靈活的程度。

Silverlight數(shù)據(jù)綁定的應(yīng)用,在實(shí)際編程中是一個(gè)非常重要的操作步驟。對(duì)于初學(xué)者來(lái)說(shuō),在剛剛學(xué)習(xí)的過(guò)程中一定要牢固掌握好這方面的知識(shí)點(diǎn),方便以后的應(yīng)用。#t#

在本示例中我們將做一個(gè)簡(jiǎn)單的Silverlight數(shù)據(jù)綁定,用來(lái)顯示用戶信息,XAML如下:

  1. < Grid x:Name="LayoutRoot" 
    Background="#46461F"> 
  2. < Grid.RowDefinitions> 
  3. < RowDefinition Height="160">
  4. < /RowDefinition> 
  5. < RowDefinition Height="40">
  6. < /RowDefinition> 
  7. < RowDefinition Height="40">
  8. < /RowDefinition> 
  9. < /Grid.RowDefinitions> 
  10. < Grid.ColumnDefinitions> 
  11. < ColumnDefinition Width="150">
  12. < /ColumnDefinition> 
  13. < ColumnDefinition Width="*">
  14. < /ColumnDefinition> 
  15. < /Grid.ColumnDefinitions> 
  16. < Image Source="terrylee.jpg" 
    Width="78" Height="100" 
  17. HorizontalAlignment="Left" 
    Grid.Row="0" Grid.Column="1"/> 
  18. < TextBlock Foreground="White" 
    FontSize="18" Text="姓名:" 
  19. Grid.Row="1" Grid.Column="0" 
    HorizontalAlignment="Right"/> 
  20. < TextBlock x:Name="lblName" 
    Foreground="White" FontSize="18" 
  21. Grid.Row="1" Grid.Column="1" 
    HorizontalAlignment="Left"/> 
  22. < TextBlock Foreground="White"
     FontSize="18" Text="位置:" 
  23. Grid.Row="2" Grid.Column="0" 
    HorizontalAlignment="Right"/> 
  24. < TextBlock x:Name="lblAddress" 
    Foreground="White" FontSize="18" 
  25. Grid.Row="2" Grid.Column="1" 
    HorizontalAlignment="Left"/> 
  26. < /Grid> 

添加一個(gè)簡(jiǎn)單User類,它具有Name和Address兩個(gè)屬性:

 

  1. public class User  
  2. {  
  3. public string Name 
    { get; set; }  
  4. public string Address 
    { get; set; }  

使用Silverlight數(shù)據(jù)綁定句法{Binding Property}進(jìn)行數(shù)據(jù)綁定,注意下面的兩個(gè)TextBlock控件Text屬性:

  1. < Grid x:Name="LayoutRoot"
     Background="#46461F"> 
  2. < Grid.RowDefinitions> 
  3. < RowDefinition Height="160">
  4. < /RowDefinition> 
  5. < RowDefinition Height="40">
  6. < /RowDefinition> 
  7. < RowDefinition Height="40">
  8. < /RowDefinition> 
  9. < /Grid.RowDefinitions> 
  10. < Grid.ColumnDefinitions> 
  11. < ColumnDefinition Width="150">
  12. < /ColumnDefinition> 
  13. < ColumnDefinition Width="*">
  14. < /ColumnDefinition> 
  15. < /Grid.ColumnDefinitions> 
  16. < Image Source="terrylee.jpg" 
    Width="78" Height="100" 
  17. HorizontalAlignment="Left" Grid.
    Row
    ="0" Grid.Column="1"/> 
  18. < TextBlock Foreground="White" 
    FontSize="18" Text="姓名:" 
  19. Grid.Row="1" Grid.Column="0" 
    HorizontalAlignment="Right"/> 
  20. < TextBlock x:Name="lblName" 
    Foreground="White" FontSize="18" 
  21. Grid.Row="1" Grid.Column="1" 
    HorizontalAlignment="Left" 
  22. Text="{Binding Name}"/> 
  23. < TextBlock Foreground="White" 
    FontSize="18" Text="位置:" 
  24. Grid.Row="2" Grid.Column="0" 
    HorizontalAlignment="Right"/> 
  25. < TextBlock x:Name="lblAddress" 
    Foreground="White" FontSize="18" 
  26. Grid.Row="2" Grid.Column="1" 
    HorizontalAlignment="Left" 
  27. Text="{Binding Address}"/> 
  28. < /Grid> 

指定數(shù)據(jù)源,注意這里是創(chuàng)建一個(gè)User的實(shí)例并賦值后,把user實(shí)例綁定到了TextBlock的DataContext上,而不是向之前我們所做的示例中那樣,直接指定Text屬性:

 

  1. private void UserControl_Loaded
    (object sender, RoutedEventArgs e)  
  2. {  
  3. User user = new User();  
  4. user.Name = "TerryLee";  
  5. user.Address = "中國(guó) 天津";  
  6. lblName.DataContext = user;  
  7. lblAddress.DataContext = user;  

上面這種Silverlight數(shù)據(jù)綁定模式,只是顯示數(shù)據(jù)而不對(duì)數(shù)據(jù)做任何修改,默認(rèn)的綁定模式是一次綁定OneTime。

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

2009-12-30 09:38:37

Silverlight

2010-04-23 13:23:42

Silverlight

2016-10-24 23:18:55

數(shù)據(jù)分析漏斗留存率

2009-12-23 10:46:38

WPF實(shí)現(xiàn)用戶界面

2009-12-30 13:51:43

Silverlight

2024-09-22 10:46:33

數(shù)據(jù)飛輪算法

2010-01-28 10:00:54

linux用戶注銷logout

2012-05-04 09:28:49

Linux

2014-07-22 14:48:05

2010-08-04 10:48:17

路由器

2009-12-30 14:10:27

Silverlight

2018-04-02 10:16:00

bug代碼安卓

2009-12-30 10:15:57

Silverlight

2016-05-17 10:03:39

用戶體驗(yàn)運(yùn)維可度量

2018-05-30 10:22:47

電商平臺(tái)

2019-08-22 15:42:03

2025-03-28 04:10:00

2025-03-05 07:58:30

2009-12-30 16:19:49

Silverlight

2010-08-05 15:06:19

Flex數(shù)據(jù)綁定
點(diǎn)贊
收藏

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

主站蜘蛛池模板: 一级片在线播放 | www.9191| 成人在线观看黄 | 五月综合激情在线 | 色婷婷激情 | 国产精品高清一区二区三区 | 精品一区二区三区中文字幕 | 国内自拍偷拍一区 | 在线播放国产一区二区三区 | 免费久久99精品国产婷婷六月 | 99精品视频在线观看免费播放 | av一区二区三区 | 久久精品美女 | www.亚洲.com | 国产精品久久午夜夜伦鲁鲁 | 日韩三级免费网站 | 日本中文在线 | 欧美极品视频在线观看 | 亚洲欧美中文日韩在线v日本 | 国产精品亚洲视频 | 波多野结衣先锋影音 | 免费观看的av毛片的网站 | 亚洲福利在线观看 | 久久一本 | 久久里面有精品 | 成人免费网站www网站高清 | 国产成人精品免费 | 欧美日韩亚洲一区 | 国产成人福利视频在线观看 | 亚洲欧美日韩国产综合 | 懂色av色香蕉一区二区蜜桃 | 日韩欧美中文在线 | 色婷婷综合久久久中字幕精品久久 | 99精品在线观看 | 成人午夜激情 | 国产精品视频一区二区三区四区国 | 成人高潮片免费视频欧美 | 国产成人免费视频网站视频社区 | 99久久婷婷国产综合精品电影 | 日韩在线不卡视频 | www.成人.com|