LongListSelector更改列表中每个项目的图像?另外,将每个项目链接到不同的.xaml页面

LongListSelector更改列表中每个项目的图像?另外,将每个项目链接到不同的.xaml页面

问题描述:

这是我当前用于主页(Longlistselector)的模板代码

Here is the template code I currently have for a home page (Longlistselector)

<phone:LongListSelector Margin="0,-38,-22,2" ItemsSource="{Binding Items}">
                    <phone:LongListSelector.ListHeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="12,0,0,38">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <TextBlock Text="second item"
                                           Style="{StaticResource PanoramaItemHeaderTextStyle}"
                                           Grid.Row="0"/>
                            </Grid>
                        </DataTemplate>
                    </phone:LongListSelector.ListHeaderTemplate>
                    <phone:LongListSelector.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="12,2,0,4" Height="105" Width="432">
                                <!--Replace rectangle with image-->
                                <Border BorderThickness="1" Width="99" Height="99" BorderBrush="#FFFFC700" Background="#FFFFC700"/>
                                <StackPanel Width="311" Margin="8,-7,0,0">
                                    <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Margin="10,0" Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="{StaticResource PhoneFontSizeLarge}" />
                                    <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="10,-2,10,0" Style="{StaticResource PhoneTextSubtleStyle}" />
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </phone:LongListSelector.ItemTemplate>
                </phone:LongListSelector>


有没有一种方法可以更改每个项目的图像,而不仅仅是一次更改所有图像?另外,是否可以从每个项目到应用程序中其他.xaml页面的链接?

Is there a way I can change the image for each item and not just for all of them at once? Also, is it possible to have links from each item to a different .xaml page in the app?

是的,是的.您可以在数据绑定项目类中为超链接添加另一个属性.

Yes, and yes. You can add another property to your databound item class for a hyperlink.

一个很好的起始示例也显示了MVVM设计模式:

A good starting sample that also shows the MVVM design pattern is:

TwitterSearch

希望这会有所帮助,
标记

Hope this helps,
Mark