日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Silverlight數(shù)據(jù)綁定實(shí)現(xiàn)用戶信息

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

為扎賚諾爾等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及扎賚諾爾網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、做網(wǎng)站、扎賚諾爾網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

在本示例中我們將做一個簡單的Silverlight數(shù)據(jù)綁定,用來顯示用戶信息,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> 

添加一個簡單User類,它具有Name和Address兩個屬性:

 
 
 
  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ù)綁定,注意下面的兩個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)建一個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 = "中國 天津";  
  6. lblName.DataContext = user;  
  7. lblAddress.DataContext = user;  

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


文章標(biāo)題:Silverlight數(shù)據(jù)綁定實(shí)現(xiàn)用戶信息
當(dāng)前URL:http://m.5511xx.com/article/djhiscc.html