[Winodows Phone 7控制項詳解]Silverlight toolkit for Windows Phone 7.1控制項-8

來源:互聯網
上載者:User

9.LongListSelector

這個控制項是一個歸類列表,並且可以快速選擇按類選擇。這個控制項最主要的是要把需要的資料進行綁定和分類,在sample中有一個People的例子(PeopleByFirstName.cs、PeopleInGroup.cs、Person.cs這幾個檔案可以看出如何?)

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            <toolkit:LongListSelector HorizontalAlignment="Left" Margin="12,46,0,0" Name="longListSelector1" VerticalAlignment="Top" Height="517" Width="438" ItemsSource="{StaticResource people}">                <toolkit:LongListSelector.GroupItemsPanel>                    <ItemsPanelTemplate>                        <toolkit:WrapPanel Orientation="Horizontal"/>                    </ItemsPanelTemplate>                </toolkit:LongListSelector.GroupItemsPanel>                <toolkit:LongListSelector.GroupItemTemplate>                    <DataTemplate>                        <Border Background="{Binding Converter={StaticResource groupbrush}}" Width="99" Height="99" Margin="6" IsHitTestVisible="{Binding HasItems}">                            <TextBlock Text="{Binding Key}"                                        FontFamily="{StaticResource PhoneFontFamilySemiBold}"                                       FontSize="36"                                       Margin="{StaticResource PhoneTouchTargetOverhang}"                                       Foreground="{StaticResource PhoneForegroundBrush}"                                                                               VerticalAlignment="Bottom"/>                        </Border>                    </DataTemplate>                </toolkit:LongListSelector.GroupItemTemplate>                <toolkit:LongListSelector.GroupHeaderTemplate>                    <DataTemplate>                        <Border Background="Transparent">                            <Border Background="{StaticResource PhoneAccentBrush}" Width="75" Height="75" HorizontalAlignment="Left">                                <TextBlock Text="{Binding Key}"                                            Foreground="{StaticResource PhoneForegroundBrush}"                                            Style="{StaticResource PhoneTextExtraLargeStyle}"                                           VerticalAlignment="Bottom"/>                            </Border>                        </Border>                    </DataTemplate>                </toolkit:LongListSelector.GroupHeaderTemplate>                <toolkit:LongListSelector.ItemTemplate>                    <DataTemplate>                        <Grid Margin="{StaticResource PhoneTouchTargetOverhang}">                            <Grid.ColumnDefinitions>                                <ColumnDefinition Width="Auto"/>                                <ColumnDefinition Width="*"/>                            </Grid.ColumnDefinitions>                            <Image Width="110" Height="150" Source="{Binding ImageUrl}" VerticalAlignment="Top"/>                            <StackPanel Grid.Column="1" VerticalAlignment="Top">                                <TextBlock Text="{Binding FullName}" Style="{StaticResource PhoneTextLargeStyle}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" Margin="12,-12,12,6"/>                                <TextBlock Text="{Binding Email}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>                                <StackPanel Orientation="Horizontal">                                    <TextBlock Text="Mobile:" Style="{StaticResource PhoneTextSmallStyle}"/>                                    <TextBlock Text="{Binding Mobile}" Style="{StaticResource PhoneTextSmallStyle}" FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>                                </StackPanel>                                <StackPanel Orientation="Horizontal">                                    <TextBlock Text="Home:" Style="{StaticResource PhoneTextSmallStyle}"/>                                    <TextBlock Text="{Binding Home}" Style="{StaticResource PhoneTextSmallStyle}" FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>                                </StackPanel>                            </StackPanel>                        </Grid>                    </DataTemplate>                </toolkit:LongListSelector.ItemTemplate>            </toolkit:LongListSelector>        </Grid>

  <toolkit:LongListSelector.GroupItemsPanel>//設定以什麼樣的方式顯示分類列表,如果沒有這個設定,分類列表以直列顯示

 <toolkit:LongListSelector.GroupItemTemplate>//分類列表內的item顯示內容和方式

  <toolkit:LongListSelector.GroupHeaderTemplate>//設定列表分類的頭的顯示內容和方式

    <toolkit:LongListSelector.ItemTemplate>//設定列表裡的內容的顯示方式

    <phone:PhoneApplicationPage.Resources>        <data:PeopleByFirstName x:Key="people"/>        <data:GroupToBrushValueConverter x:Key="groupbrush"/>    </phone:PhoneApplicationPage.Resources>
xmlns:data="clr-namespace:testNewControls.Data"

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.