# C1.WPF.LiveLinq.WpfExtensions.ToIndexed

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_WPF_LiveLinq_WpfExtensions_ToIndexed_" data-uid="C1.WPF.LiveLinq.WpfExtensions.ToIndexed*">ToIndexed Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_WPF_LiveLinq_WpfExtensions_ToIndexed_" data-uid="C1.WPF.LiveLinq.WpfExtensions.ToIndexed*"></a>
<h4 id="C1_WPF_LiveLinq_WpfExtensions_ToIndexed__1_System_Collections_Specialized_INotifyCollectionChanged_" data-uid="C1.WPF.LiveLinq.WpfExtensions.ToIndexed``1(System.Collections.Specialized.INotifyCollectionChanged)">ToIndexed&lt;T&gt;(INotifyCollectionChanged)</h4>
<div class="markdown level1 summary"><p>Creates an <a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection&lt;T&gt;</a> based on the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.specialized.inotifycollectionchanged">INotifyCollectionChanged</a> data source.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static IndexedCollection&lt;T&gt; ToIndexed&lt;T&gt;(this INotifyCollectionChanged source)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function ToIndexed(Of T)(source As INotifyCollectionChanged) As IndexedCollection(Of T)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.specialized.inotifycollectionchanged">INotifyCollectionChanged</a></td>
      <td><span class="parametername">source</span></td>
      <td><p>An <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.specialized.inotifycollectionchanged">INotifyCollectionChanged</a> data source to represent as an <a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection&lt;T&gt;</a>.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection</a>&lt;T&gt;</td>
      <td><p>An <a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection&lt;T&gt;</a> that contains the same elements as the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.specialized.inotifycollectionchanged">INotifyCollectionChanged</a>
and enables indexing of that data source.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td><p>The type of the elements in the collection.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_WPF_LiveLinq_WpfExtensions_ToIndexed__1_System_Collections_Specialized_INotifyCollectionChanged__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Use this method to index and query your existing data sources implementing <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.specialized.inotifycollectionchanged">INotifyCollectionChanged</a>.
The element type of this data source must implement <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.componentmodel.inotifypropertychanged">INotifyPropertyChanged</a>,
see <span style="C1H Jump">Using the built-in collection class IndexedCollection(T) (LiveLinq to Objects)|tag=Using_the_built_in_collection_class_IndexedCollectionT_LiveLinq_to_Objects</span>.</p>
<p> The collection returned by this method also implements the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.specialized.inotifycollectionchanged">INotifyCollectionChanged</a> interface,
because this method actually returns objects of an internal derived class that implements that interface.</p>
<p><b>Note: </b>Indexes created on the resulting  <a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection&lt;T&gt;</a> are owned by it
and not by the original data source. Every <b>ToIndexed()</b> call creates a separate object that
has its own separate indexes. Avoid calling <b>ToIndexed()</b> repeatedly 
for the same collection because it can increase the cost of maintaining indexes.</p>
</div>


<a id="C1_WPF_LiveLinq_WpfExtensions_ToIndexed_" data-uid="C1.WPF.LiveLinq.WpfExtensions.ToIndexed*"></a>
<h4 id="C1_WPF_LiveLinq_WpfExtensions_ToIndexed__1_System_Collections_ObjectModel_ObservableCollection___0__" data-uid="C1.WPF.LiveLinq.WpfExtensions.ToIndexed``1(System.Collections.ObjectModel.ObservableCollection{``0})">ToIndexed&lt;T&gt;(ObservableCollection&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>A typed specialization of the <a class="xref" href="C1.WPF.LiveLinq.WpfExtensions.ToIndexed.html#C1_WPF_LiveLinq_WpfExtensions_ToIndexed__1_System_Collections_Specialized_INotifyCollectionChanged_">ToIndexed&lt;T&gt;(INotifyCollectionChanged)</a> method.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static IndexedCollection&lt;T&gt; ToIndexed&lt;T&gt;(this ObservableCollection&lt;T&gt; source)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function ToIndexed(Of T)(source As ObservableCollection(Of T)) As IndexedCollection(Of T)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.observablecollection-1">ObservableCollection</a>&lt;T&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>An <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.observablecollection-1">ObservableCollection&lt;T&gt;</a>  represent as an <a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection&lt;T&gt;</a>.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection</a>&lt;T&gt;</td>
      <td><p>An <a class="xref" href="C1.LiveLinq.Collections.IndexedCollection-1.html">IndexedCollection&lt;T&gt;</a> that contains the same elements as the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.observablecollection-1">ObservableCollection&lt;T&gt;</a>
and enables indexing of that collection.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td><p>The type of the elements in the collection.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
