Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 8 如何在WP8中实现多选照片页?_Windows Phone 8 - Fatal编程技术网

Windows phone 8 如何在WP8中实现多选照片页?

Windows phone 8 如何在WP8中实现多选照片页?,windows-phone-8,Windows Phone 8,我知道现在在WindowsPhone8.1和Windows8.1中,使用FileOpenPicker选择多张照片很容易 但在Windows Phone 8.0中,只有本机代码可以访问API,因此如果我们必须选择多张照片来执行某些操作(如上载),我们必须通过toolkit:LongListMultiSelector来实现它 这样做,我就有了性能问题 以下是XAML: <ScrollViewer x:Name="ScrowllViewAlbum" HorizontalAlignment="Le

我知道现在在WindowsPhone8.1和Windows8.1中,使用FileOpenPicker选择多张照片很容易

但在Windows Phone 8.0中,只有本机代码可以访问API,因此如果我们必须选择多张照片来执行某些操作(如上载),我们必须通过toolkit:LongListMultiSelector来实现它

这样做,我就有了性能问题

以下是XAML:

<ScrollViewer x:Name="ScrowllViewAlbum" HorizontalAlignment="Left" Height="500" VerticalAlignment="Top" Width="458" >
                <toolkit:LongListMultiSelector 
                    x:Name="AlbumList"
                    IsGroupingEnabled="False"
                    GridCellSize="100,100"
                    LayoutMode="Grid"
                    HideEmptyGroups="True"
                    IsSelectionEnabled="False"
                    EnforceIsSelectionEnabled="False"
                    CacheMode="BitmapCache"
                    ItemsSource="{Binding}" 
                    Width="459"
                    ItemTemplate="{StaticResource AllPhotoTemplete}" Background="Black"
                />
            </ScrollViewer>

在ViewModel中:

  public void LoadAllPhotos()
    {
        Allphotos = new ObservableCollection<BitmapImage>();
        MediaLibrary medialib = new MediaLibrary();
        PictureCollection pics =  medialib.Pictures;

        if (pics.Count!=0)
        {
            BitmapImage image = new BitmapImage();
           foreach(var pic in pics)
           {         
                   Stream stream = pic.GetImage();
                   image.SetSource(stream);
                   Allphotos.Add(image);
           }
       }
    }
public void LoadAllPhotos()
{
Allphotos=新的ObservableCollection();
MediaLibrary medialib=新的MediaLibrary();
PictureCollection pics=媒体库图片;
如果(图片计数!=0)
{
BitmapImage=新的BitmapImage();
foreach(pics中的var pic)
{         
Stream=pic.GetImage();
image.SetSource(流);
所有照片。添加(图像);
}
}
}
但是,在调试过程中,它抛出了一个异常,即没有内存不足

你能给我一些优化功能的想法吗


谢谢:-)

没有其他方法可以自己实现选择器

由于您仅为预览加载图像,因此仅加载缩略图,如下所示:

var image = new BitmapImage();
image.SetSource(pic.GetThumbnail());

您询问了一些优化功能的想法。你能提高内存消耗吗?