Windows phone 7 带有多个捕获图像的列表框windows phone

Windows phone 7 带有多个捕获图像的列表框windows phone,windows-phone-7,windows-phone-8,windows-phone,image-gallery,listboxitem,Windows Phone 7,Windows Phone 8,Windows Phone,Image Gallery,Listboxitem,有人知道如何制作包含多个图像的列表框吗。我希望能够捕获一个图像,然后显示在屏幕上,然后捕获另一个图像,并在第一个图像之后显示,依此类推。这基本上是我想要创建的图像库页面。我想将它们存储在手机上的某个位置,以便在应用程序再次运行时检索它们 因此,它应该像图中所示: 提前谢谢你,我一直在做这方面的研究,但找不到任何东西 嗯,那相当容易。使用列表框将ItemsPanel设置为WrapPanel,并将ItemsSource绑定到ObservableCollection(或列表/数组,但Observabl

有人知道如何制作包含多个图像的列表框吗。我希望能够捕获一个图像,然后显示在屏幕上,然后捕获另一个图像,并在第一个图像之后显示,依此类推。这基本上是我想要创建的图像库页面。我想将它们存储在手机上的某个位置,以便在应用程序再次运行时检索它们

因此,它应该像图中所示:


提前谢谢你,我一直在做这方面的研究,但找不到任何东西

嗯,那相当容易。使用列表框将ItemsPanel设置为WrapPanel,并将ItemsSource绑定到ObservableCollection(或列表/数组,但ObservableCollection更适合绑定)

有多种方法可以做到这一点 让我们采取最简单的方法。在xaml中定义列表框:

<ListBox x:Name="listbox">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>

            <toolkit:WrapPanel />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>

        <DataTemplate>
            <Grid Margin="5"
                  Background="{StaticResource PhoneChromeBrush}"
                  Height="180"
                  Width="180">
                <Image Source="{Binding}" />
            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
提供图像是您设置为列表框的ItemsSource的
ObservableCollection


这几乎是你的全功能应用程序,与上面的链接兼容。

@Stefan。。谢谢,这给了我一个大概的想法,我想,但如果有任何示例应用程序,或完整的源代码,这将是非常有帮助的,谢谢一次again@Stefan.. 我对您的xaml代码非常满意,但是当涉及到它的实际代码时,我觉得我有点沮丧。我想要做的就是有一个页面,它允许我捕获图像并将它们保存到独立的存储中,然后检索相同的图像并在页面上显示,等等。因此,我希望该页面能够将许多捕获的图片存储为列表。无论如何谢谢你的帮助,希望你能帮助我further@Jordan见我的编辑,现在你基本上只需要复制所有的代码,你有你的app@Stefan.. 非常感谢你帮助我。我已经复制了你的代码并放在了我想要的页面上,它工作得很好,唯一没有做的就是将图像保存到独立的存储中,我必须想办法,谢谢again@Jordan看看我答案中的链接,有一种保存图像的方法。您只需更改一行代码即可(这里是链接:)。如果这对您有帮助,请将答案标记为已回答。
ObservableCollection<BitmapImage> images = new ObservableCollection<BitmapImage>();
List<String> bitmapuris = ....
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
    foreach(var bitmapuri in bitmapuris)
    {
        System.Windows.Media.Imaging.BitmapImage bitmap = new System.Windows.Media.Imaging.BitmapImage();

        if (isoStore.FileExists(bitmapuri))
        {
            using (IsolatedStorageFileStream stream = isoStore.OpenFile(bitmapuri, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                bitmap.CreateOptions = System.Windows.Media.Imaging.BitmapCreateOptions.BackgroundCreation;
                bitmap.SetSource(stream);
            }
        }
        images.Add(bitmap);
    }
}
listbox.ItemsSource = images;
List<String> getFiles(String folderpath)
{
    IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
    return storage.GetFileNames(folderpath).ToList();
}
System.Windows.Media.Imaging.BitmapImage bitmap = new System.Windows.Media.Imaging.BitmapImage();
bitmap.CreateOptions = System.Windows.Media.Imaging.BitmapCreateOptions.BackgroundCreation;
bitmap.SetSource(myimagestream);
images.Add(bitmap);