<bdo id='mgYfI'></bdo><ul id='mgYfI'></ul>
  • <tfoot id='mgYfI'></tfoot>

    1. <small id='mgYfI'></small><noframes id='mgYfI'>

        <legend id='mgYfI'><style id='mgYfI'><dir id='mgYfI'><q id='mgYfI'></q></dir></style></legend>
      1. <i id='mgYfI'><tr id='mgYfI'><dt id='mgYfI'><q id='mgYfI'><span id='mgYfI'><b id='mgYfI'><form id='mgYfI'><ins id='mgYfI'></ins><ul id='mgYfI'></ul><sub id='mgYfI'></sub></form><legend id='mgYfI'></legend><bdo id='mgYfI'><pre id='mgYfI'><center id='mgYfI'></center></pre></bdo></b><th id='mgYfI'></th></span></q></dt></tr></i><div id='mgYfI'><tfoot id='mgYfI'></tfoot><dl id='mgYfI'><fieldset id='mgYfI'></fieldset></dl></div>

        在虚拟化列表框中延迟加载图像

        Lazy loading images in Virtualized Listbox(在虚拟化列表框中延迟加载图像)

          <i id='wHM5p'><tr id='wHM5p'><dt id='wHM5p'><q id='wHM5p'><span id='wHM5p'><b id='wHM5p'><form id='wHM5p'><ins id='wHM5p'></ins><ul id='wHM5p'></ul><sub id='wHM5p'></sub></form><legend id='wHM5p'></legend><bdo id='wHM5p'><pre id='wHM5p'><center id='wHM5p'></center></pre></bdo></b><th id='wHM5p'></th></span></q></dt></tr></i><div id='wHM5p'><tfoot id='wHM5p'></tfoot><dl id='wHM5p'><fieldset id='wHM5p'></fieldset></dl></div>
            <tbody id='wHM5p'></tbody>
            • <tfoot id='wHM5p'></tfoot>

                <bdo id='wHM5p'></bdo><ul id='wHM5p'></ul>
                <legend id='wHM5p'><style id='wHM5p'><dir id='wHM5p'><q id='wHM5p'></q></dir></style></legend>
              • <small id='wHM5p'></small><noframes id='wHM5p'>

                  本文介绍了在虚拟化列表框中延迟加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试异步延迟加载列表框中每个项目的缩略图.

                  I'm trying to lazy load thumbnail image for each item in a Listbox asynchronously.

                  <Image Source="{Binding Path=Thumbnail, TargetNullValue={StaticResource DefaultImage}}"/>
                  

                  由于 Listbox 是虚拟化的,Thumbnail 属性的 getter 仅在项目位于显示端口或靠近显示端口时被调用.

                  Since Listbox is virtualized Thumbnail property's getter is called only when an item is in display port or near to that.

                  public BitmapSource Thumbnail
                  {
                      get
                      {
                          TriggerLoad();
                          return _thumbnail;
                      }
                  }
                  

                  我正在等待在 TriggerLoad 函数中加载 Thumbail 的昂贵操作,但 UI 响应不快,尤其是当您尝试快速滚动浏览大量项目时.

                  I am awaiting on expensive operation that loads Thumbail in TriggerLoad function, but UI isn't very responsive especially when you try to scroll fastly through large list of items.

                  private async void TriggerLoad()
                  {
                      if (!LoadTriggered)
                      {
                          LoadTriggered = true;
                          var cacheItem = _cache[key] as CacheItem;
                  
                          if (cacheItem != null)
                              await LoadBitmapFromCache(cacheItem); // returns a Task
                          else
                              await LoadBitmapFromService(Id); // returns a Task
                      }
                  }
                  

                  在这里找到了类似的问题,但这与将项目加载到列表框无关.有没有更好的方法来延迟加载您绑定到 Listbox 的部分数据?

                  Found a similar questions here but it is not about loading items to a Listbox. Is there any better approach to lazy load only some part of the data you bind to Listbox?

                  我尝试了 PriorityBinding 和 IsAsync 选项,滚动并不比我当前的解决方案好.

                  I tried PriorityBinding and IsAsync option and scrolling is not better than my current solution.

                  推荐答案

                  听起来虽然你的 UI 是虚拟化的,但它加载新图像的速度不足以跟上用户的滚动.尝试将 VirtualizationMode 设置为 Recycling 并设置更长的 CacheLength.像这样:

                  Sounds like although your UI is virtualizing it isn't loading newer images quickly enough to keep up with your user's scrolling. Try setting VirtualizationMode to Recycling and set a longer CacheLength. Like so:

                  <ListBox
                      VirtualizingPanel.IsContainerVirtualizable="True"
                      VirtualizingPanel.IsVirtualizing="True"
                      VirtualizingPanel.VirtualizationMode="Recycling"
                      VirtualizingPanel.CacheLengthUnit="Page"
                      VirtualizingPanel.CacheLength="2,2"
                      etc.../>
                  

                  将 CacheLength 从1,1"增加到2,2"意味着在向用户显示的页面之前和之后将两个页面"(或相当于项目的视口)加载到内存中.您的应用会消耗更多的内存,但用户可以在遇到未加载的图像之前滚动得更快、更远.

                  Increasing CacheLength from "1,1" to "2,2" means two "pages" (or view-ports worth of items) will be loaded into memory before and after the page displayed to the user. Your app will consume that much more memory but users will be able to scroll further, faster, before running into images that aren't loaded.

                  这篇关于在虚拟化列表框中延迟加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                  1. <i id='0SMBK'><tr id='0SMBK'><dt id='0SMBK'><q id='0SMBK'><span id='0SMBK'><b id='0SMBK'><form id='0SMBK'><ins id='0SMBK'></ins><ul id='0SMBK'></ul><sub id='0SMBK'></sub></form><legend id='0SMBK'></legend><bdo id='0SMBK'><pre id='0SMBK'><center id='0SMBK'></center></pre></bdo></b><th id='0SMBK'></th></span></q></dt></tr></i><div id='0SMBK'><tfoot id='0SMBK'></tfoot><dl id='0SMBK'><fieldset id='0SMBK'></fieldset></dl></div>
                    <tfoot id='0SMBK'></tfoot>
                  2. <small id='0SMBK'></small><noframes id='0SMBK'>

                    <legend id='0SMBK'><style id='0SMBK'><dir id='0SMBK'><q id='0SMBK'></q></dir></style></legend>
                      • <bdo id='0SMBK'></bdo><ul id='0SMBK'></ul>
                          <tbody id='0SMBK'></tbody>