在Windows Phone 8中的文件夹中的stackpanel或Listbox中加载60个图像

时间:2014-09-19 08:39:04

标签: c# xaml windows-phone-8

如何从windows phone 8(C#和Xaml)中的文件夹中加载60个图像到stackpanel或Listbox中,当我点击特定按钮时,我会从另一个文件夹中加载另一个图像?

1 个答案:

答案 0 :(得分:0)

以下是我用来列出图片的代码,

<ListBox SelectionMode="Single" 
        ScrollViewer.VerticalScrollBarVisibility="Disabled" 
        ScrollViewer.HorizontalScrollBarVisibility="Auto" 
        ItemsSource="{Binding ImageCollection}" 
        SelectedItem="{Binding SelectedImage}" 
        MinHeight="100">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Image Source="{Binding}" Width="50" Margin="5"/>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

这里,ImageCollection是

public static IEnumerable<Uri> ImageCollection { get; set; }

将包含你的形象Uri&#39>

希望这会有所帮助