title: Xamarin Forms CollectionView Select All Items
body: <p>I am using the multi-platform Xamarin forms, and I want to be able to click a button and select all the items inside a <code>collectionview</code>.</p>
  <p>I have :</p>
  <pre><code>&lt;CollectionView x:Name=&quot;collectionList&quot; SelectionMode=&quot;Multiple&quot;
                              SelectionChanged=&quot;RowSelected&quot;
                              ItemsSource=&quot;{Binding ContentList}&quot;&gt;
  </code></pre>
  <p>and inside the cs file:</p>
  <pre><code>ObservableCollection ContentList = //list made in an earlier method, this is confirmed working
  collectionList.SelectedItems= ContentList; //executes on the button click event
  </code></pre>
  <p>However that does not work as <strong>SelectedItems</strong> requires an <strong>IList</strong> which does not accept normal <strong>List</strong> or <strong>ObservableCollection</strong>. I also tried setting the <strong>SelectedItems</strong> to collectionList.ItemsSource (the collectionview source) but that gave the same type error which is <code>Cannot implicitly convert type 'System.Collections.Generic.List&lt;object&gt;' to 'System.Collections.Generic.IList&lt;object&gt;' </code></p>
  <p>What I have currently working is that the <code>collectionview</code> populates with data, and multiple items can be manually selected by the user. This returns me the items that were tapped. I cannot get the view to select everything programmatically though.</p>
  <p>I have searched all over and I haven't seen any posts trying to do this, what is the best approach to making a &quot;select all&quot; button for collectionviews?</p>
  <p>Edit: The problem was that my list had a defined class as the list type and it needed to be of type <code>object</code> as listed in the accepted answer below</p>