久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <i id='KVYBt'><tr id='KVYBt'><dt id='KVYBt'><q id='KVYBt'><span id='KVYBt'><b id='KVYBt'><form id='KVYBt'><ins id='KVYBt'></ins><ul id='KVYBt'></ul><sub id='KVYBt'></sub></form><legend id='KVYBt'></legend><bdo id='KVYBt'><pre id='KVYBt'><center id='KVYBt'></center></pre></bdo></b><th id='KVYBt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KVYBt'><tfoot id='KVYBt'></tfoot><dl id='KVYBt'><fieldset id='KVYBt'></fieldset></dl></div>

        <small id='KVYBt'></small><noframes id='KVYBt'>

        <legend id='KVYBt'><style id='KVYBt'><dir id='KVYBt'><q id='KVYBt'></q></dir></style></legend>

        <tfoot id='KVYBt'></tfoot>
          <bdo id='KVYBt'></bdo><ul id='KVYBt'></ul>

        有效地將一系列值添加到 ObservableCollection

        Adding a range of values to an ObservableCollection efficiently(有效地將一系列值添加到 ObservableCollection)

              <bdo id='7h2Tc'></bdo><ul id='7h2Tc'></ul>
                <tbody id='7h2Tc'></tbody>
              <i id='7h2Tc'><tr id='7h2Tc'><dt id='7h2Tc'><q id='7h2Tc'><span id='7h2Tc'><b id='7h2Tc'><form id='7h2Tc'><ins id='7h2Tc'></ins><ul id='7h2Tc'></ul><sub id='7h2Tc'></sub></form><legend id='7h2Tc'></legend><bdo id='7h2Tc'><pre id='7h2Tc'><center id='7h2Tc'></center></pre></bdo></b><th id='7h2Tc'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7h2Tc'><tfoot id='7h2Tc'></tfoot><dl id='7h2Tc'><fieldset id='7h2Tc'></fieldset></dl></div>

                <tfoot id='7h2Tc'></tfoot>
              • <legend id='7h2Tc'><style id='7h2Tc'><dir id='7h2Tc'><q id='7h2Tc'></q></dir></style></legend>
              • <small id='7h2Tc'></small><noframes id='7h2Tc'>

                  本文介紹了有效地將一系列值添加到 ObservableCollection的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有一個 ObservableCollection 項目綁定到我的視圖中的列表控件.

                  I have an ObservableCollection of items that is bound to a list control in my view.

                  我有一種情況,我需要在集合的開頭添加一大塊值.Collection<T>.Insert 文檔將每個插入指定為 O(n) 操作,并且每個插入還會生成一個 CollectionChanged 通知.

                  I have a situation where I need to add a chunk of values to the start of the collection. Collection<T>.Insert documentation specifies each insert as an O(n) operation, and each insert also generates a CollectionChanged notification.

                  因此,理想情況下,我希望一次插入整個項目范圍,這意味著只對底層列表進行一次隨機播放,并希望有一個 CollectionChanged 通知(可能是重置").

                  Therefore I would ideally like to insert the whole range of items in one move, meaning only one shuffle of the underlying list, and hopefully one CollectionChanged notification (presumably a "reset").

                  Collection<T> 沒有公開任何執行此操作的方法.ListInsertRange(),但是 IListCollection 通過它的 Items 屬性沒有.

                  Collection<T> does not expose any method for doing this. List<T> has InsertRange(), but IList<T>, that Collection<T> exposes via its Items property does not.

                  有沒有辦法做到這一點?

                  Is there any way at all to do this?

                  推薦答案

                  ObservableCollection 公開了一個受保護的 Items 屬性,該屬性是沒有通知語義的底層集合.這意味著您可以通過繼承 ObservableCollection 來構建一個可以滿足您需求的集合:

                  The ObservableCollection exposes an protected Items property which is the underlying collection without the notification semantics. This means you can build a collection that does what you want by inheriting ObservableCollection:

                  class RangeEnabledObservableCollection<T> : ObservableCollection<T>
                  {
                      public void InsertRange(IEnumerable<T> items) 
                      {
                          this.CheckReentrancy();
                          foreach(var item in items)
                              this.Items.Add(item);
                          this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                      }
                  }
                  

                  用法:

                  void Main()
                  {
                      var collection = new RangeEnabledObservableCollection<int>();
                      collection.CollectionChanged += (s,e) => Console.WriteLine("Collection changed");
                      collection.InsertRange(Enumerable.Range(0,100));
                      Console.WriteLine("Collection contains {0} items.", collection.Count);  
                  }
                  

                  這篇關于有效地將一系列值添加到 ObservableCollection的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
                • <i id='9oE2A'><tr id='9oE2A'><dt id='9oE2A'><q id='9oE2A'><span id='9oE2A'><b id='9oE2A'><form id='9oE2A'><ins id='9oE2A'></ins><ul id='9oE2A'></ul><sub id='9oE2A'></sub></form><legend id='9oE2A'></legend><bdo id='9oE2A'><pre id='9oE2A'><center id='9oE2A'></center></pre></bdo></b><th id='9oE2A'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9oE2A'><tfoot id='9oE2A'></tfoot><dl id='9oE2A'><fieldset id='9oE2A'></fieldset></dl></div>

                    <tfoot id='9oE2A'></tfoot>
                  1. <legend id='9oE2A'><style id='9oE2A'><dir id='9oE2A'><q id='9oE2A'></q></dir></style></legend>

                    <small id='9oE2A'></small><noframes id='9oE2A'>

                          <tbody id='9oE2A'></tbody>
                          • <bdo id='9oE2A'></bdo><ul id='9oE2A'></ul>
                          • 主站蜘蛛池模板: 九九久久久 | 特级黄色毛片 | 午夜精品一区 | 自拍视频网站 | 久久精品日 | 久久99精品久久久久久青青日本 | 精品综合| 国产精品无码专区在线观看 | av毛片 | 精品国产欧美 | 亚欧洲精品在线视频免费观看 | 午夜在线视频一区二区三区 | 91精品国产91久久久久久最新 | 狠狠av| 色综合九九 | 久久久久久久久91 | 国产精品久久久久久久久久三级 | 久久久新视频 | 亚洲精品一区二区三区在线 | 亚洲精品成人免费 | 国产在线观看一区二区 | 国产一区二区在线免费观看 | 狠狠干2020 | 欧美成人精品一区二区三区 | 一级毛片在线播放 | 欧美日韩在线一区 | 成人欧美一区二区三区黑人孕妇 | 欧洲性生活视频 | 精品免费国产视频 | 国产ts人妖另类 | 亚洲精品 在线播放 | 久久夜夜| 黄色大片在线视频 | 91精品久久久久久久99 | 一区二区三区 在线 | av激情影院 | 成人网视频 | 青青久久久| 国产视频一区在线观看 | 黄a网| 欧美老妇交乱视频 |