簡體   English   中英

使用WrapPanel來自URL的Windows Phone 7的方形照片網格

[英]Grid of square photos from URLs Windows Phone 7 using WrapPanel

我有一個返回約100張照片的Web服務,我想在Windows Phone 7的3xN網格中顯示所有照片。

我已經嘗試了WrapPanel,它可以工作,但是只顯示了幾張圖像。還有更多,而且我的內存不足並調試暫停。

碼:

<ListBox Height="600" HorizontalAlignment="Left" Name="screenshotsListBox" VerticalAlignment="Top" Width="420">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Image Source="{Binding}"
                Margin="0"
                Height="110"
                Width="110"
                CacheMode="BitMapCache"
                Stretch="UniformToFill"
                Grid.Row="0" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

我將所有圖像放置在字符串數組中,然后將其綁定到listBox。

我可以做些什么來顯示從Web服務下載的照片網格而不占用所有內存? 謝謝

我建議對代碼進行概要分析,以找出造成內存使用量的真正原因,但我猜想,如果僅將它們顯示為110x110px,則您可能正在[下載]大於所需大小的圖像版。 即使您顯示它們被拉伸(縮小)到較小的尺寸,整個圖像也會加載到內存中。 如果它們是大圖像,則內存使用將很快增加。

http://blogs.msdn.com/b/swick/archive/2011/04/07/image-tips-for-windows-phone-7.aspx上,有一些與圖像和內存有關的有用提示。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM