LongListSelector专注于项目

时间:2013-02-10 09:55:20

标签: c# .net silverlight windows-phone-7 listbox

我在我的应用页面中有这个LongListSelector:

<Controls:LongListSelector x:Name="searchList" Margin="0,0,0,0"  Background="White" SelectionChanged="DidPressSelectSearchList" HorizontalContentAlignment="Stretch" Grid.Row="1">
            <Controls:LongListSelector.ItemTemplate>
                <DataTemplate>
                        <local:SearchTemplateSelector Content="{Binding}" HorizontalContentAlignment="Stretch">
                        <local:SearchTemplateSelector.GoogleSuggestTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Rectangle Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="Black" Opacity="0.3"/>
                                    <TextBlock Text="{Binding}" FontSize="25" Foreground="Black" TextWrapping="Wrap" Grid.Row="1" Margin="0,10"/>
                                </Grid>
                            </DataTemplate>
                        </local:SearchTemplateSelector.GoogleSuggestTemplate>

                        <local:SearchTemplateSelector.VideoTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Rectangle Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="Black" Opacity="0.3" />
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="100" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Image Margin="0" Source="{Binding Path=ImgUrl}" HorizontalAlignment="Left" Width="100" Height="100" Tag="{Binding idStr}"/>
                                        <Grid Grid.Column="1" Margin="10,0,8,0">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="60"/>
                                                <RowDefinition Height="*"/>
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>
                                            <TextBlock Text="{Binding Name}" FontSize="20" Foreground="Black" TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                            <StackPanel Orientation="Horizontal" Margin="0,-5,0,0" Grid.Row="1">
                                                <TextBlock Text="Views:  " FontSize="20" Foreground="Black"/>
                                                <TextBlock Text="{Binding ViewCount}" FontSize="20" Foreground="Black"/>
                                            </StackPanel>

                                            <Grid Grid.Row="2">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>

                                                <TextBlock Text="{Binding TimeStr}" FontSize="20" Foreground="Black" Margin="0,0,0,0" />
                                                <TextBlock Text="Cached" FontSize="20" Foreground="Red" Margin="20,0,0,0" Grid.Column="1" />
                                            </Grid>
                                        </Grid>
                                    </Grid>

                                </Grid>

                            </DataTemplate>
                        </local:SearchTemplateSelector.VideoTemplate>

                    </local:SearchTemplateSelector>
                </DataTemplate>


            </Controls:LongListSelector.ItemTemplate>
        </Controls:LongListSelector>

我注意到,当我按下列表中的某个项目,这样用户就没有任何东西可以知道他按下了哪个项目,就像按下它时对焦项目。 在iPhone中,所选行变为蓝色,当释放时蓝色选择消失,在Windows手机中也有一些相当于这个?

1 个答案:

答案 0 :(得分:2)

使用Silverlight Toolkit for Windows Phone中的TiltEffect,详情请访问http://www.geekchamp.com/articles/silverlight-for-wp7-toolkit-tilteffect-in-depth。另外,要使效果更具表现力,请使用Button作为ItemTemplate EmptyButtonStyle与{{1}} http://www.jeff.wilcox.name/2011/10/hyperlinkbutton-empty-style-for-phone/的容器。