C# 在列表框windows phone 8中启用可视化
我试图在手机中显示高质量的图像,因为我的图像太大,应用程序显示内存警告异常。所以我尝试了可视化,但每次列表框加载时,它都会加载整个数据 xaml代码:C# 在列表框windows phone 8中启用可视化,c#,.net,windows-phone-8,virtualization,C#,.net,Windows Phone 8,Virtualization,我试图在手机中显示高质量的图像,因为我的图像太大,应用程序显示内存警告异常。所以我尝试了可视化,但每次列表框加载时,它都会加载整个数据 xaml代码: <ListBox x:Name="ImageStack" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibili
<ListBox x:Name="ImageStack"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
VirtualizingStackPanel.VirtualizationMode="Recycling"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"></VirtualizingStackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Resources>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Image Source="{Binding bimage}" />
<TextBlock Text="{Binding impath}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
在虚拟歌曲列表类中
object IList.this[int index]
{
get
{
// here is where the magic happens, create/load your data on the fly.
// Debug.WriteLine("Requsted item " + index.ToString());
System.Diagnostics.Debug.WriteLine(index.ToString());
return new im { impath = "yyyyyyyyy", bimage = new BitmapImage(new Uri(@"Assets/c"+index+".png", UriKind.Relative)) };
}
set
{
throw new NotImplementedException();
}
}
有谁能提出一种在windows中显示高质量图像的有效方法吗?使用基于虚拟化的LongListSelector。 即使在这种情况下,如果你对图像记忆太过激进,它也可能无法解决你的问题。 由于WP屏幕中的空间有限,请尝试制作并显示图像的缩略图,而不是首先使用BitmapImage::DecodePixelHeight和BitmapImage::DecodePixelWidth来解码整个图像,从而将整个图像存储在内存中。当用户选择这样做时,您仍然可以在详细信息页面中显示完整大小的图像,一次显示一个。
还可以尝试试用BitmapImage::CacheOption(或其他缓存技术),看看如何更好地检查内存。我认为您应该改用longlistselector。尽管有一些问题,但据我所知,这将使您能够获得更多的数据。
object IList.this[int index]
{
get
{
// here is where the magic happens, create/load your data on the fly.
// Debug.WriteLine("Requsted item " + index.ToString());
System.Diagnostics.Debug.WriteLine(index.ToString());
return new im { impath = "yyyyyyyyy", bimage = new BitmapImage(new Uri(@"Assets/c"+index+".png", UriKind.Relative)) };
}
set
{
throw new NotImplementedException();
}
}