av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

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

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

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

在本示例中我們將做一個簡單的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}進行數(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的實例并賦值后,把user實例綁定到了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ù)做任何修改,默認的綁定模式是一次綁定OneTime。


分享題目:Silverlight數(shù)據(jù)綁定實現(xiàn)用戶信息
本文鏈接:http://uogjgqi.cn/article/djhiscc.html
掃二維碼與項目經理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網交流