新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Silverlight綁定到列表相關技巧
Silverlight中的數(shù)據(jù)綁定是一個非常重要的部分。它的靈活運用,使我們在開發(fā)過程中能夠輕松自如的實現(xiàn)各種功能的需求。在這里我們就為大家介紹一種是用技巧,Silverlight綁定到列表的實現(xiàn)方法。#t#

為克東等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及克東網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為成都網(wǎng)站建設、成都做網(wǎng)站、克東網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
下面再看一個Silverlight綁定到列表的簡單例子,一般都會使用DataGrid或者ListBox來進行列表數(shù)據(jù)的顯示。下面的示例我們顯示一個文章列表:
- < Grid Background="#46461F">
- < Grid.RowDefinitions>
- < RowDefinition Height="40">
- < /RowDefinition>
- < RowDefinition Height="*">
- < /RowDefinition>
- < /Grid.RowDefinitions>
- < Grid.ColumnDefinitions>
- < ColumnDefinition>
- < /ColumnDefinition>
- < /Grid.ColumnDefinitions>
- < Border Grid.Row="0"
Grid.Column="0" CornerRadius="15" - Width="240" Height="36"
Background="Orange" - Margin="20 0 0 0" Horizontal
Alignment="Left"> - < TextBlock Text="文章列表"
Foreground="White" - HorizontalAlignment="Left"
VerticalAlignment="Center" - Margin="20 0 0 0">< /TextBlock>
- < /Border>
- < ListBox x:Name="PostList"
Grid.Column="0" Grid.Row="1" - Margin="40 10 10 10"
- HorizontalContentAlignment="Left"
VerticalContentAlignment="Bottom" - ItemsSource="{Binding Posts}">
- < /ListBox>
- < /Grid>
編寫一個簡單的Silverlight綁定到列表的業(yè)務類:
- public class Blog
- {
- public List< String>
Posts { get; set; }- }
初始化集合數(shù)據(jù)并進行綁定
- private void UserControl_Loaded
(object sender, RoutedEventArgs e)- {
- Blog blog = new Blog();
- blog.Posts = new List< String>
- {
- "一步一步學Silverlight 2系列
(10):使用用戶控件",- "一步一步學Silverlight 2系列
(9):使用控件模板",- "一步一步學Silverlight 2系列
(8):使用樣式封裝控件觀感",- "一步一步學Silverlight 2系列
(7):全屏模式支持"- };
- PostList.DataContext = blog;
- }
Silverlight綁定到列表相關實現(xiàn)方法就為大家介紹到這里。
網(wǎng)頁標題:Silverlight綁定到列表相關技巧
文章位置:http://fisionsoft.com.cn/article/cddgcjs.html


咨詢
建站咨詢
