Skip to content

Instantly share code, notes, and snippets.

@dayneo
Created February 11, 2016 16:44
Show Gist options
  • Select an option

  • Save dayneo/1e0f826d50c80aa5c841 to your computer and use it in GitHub Desktop.

Select an option

Save dayneo/1e0f826d50c80aa5c841 to your computer and use it in GitHub Desktop.
Extends ListCollectionView to provide indexer based access to CollectionViewSource sources in XAML binding.
using System;
using System.Collections;
using System.Windows.Data;
public class IndexAccessibleListCollectionView : ListCollectionView
{
public IndexAccessibleListCollectionView(IEnumerable collection)
: base(new ArrayList())
{
foreach (object item in collection)
{
base.InternalList.Add(item);
}
}
public object this[int index]
{
get
{
return this.GetItemAt(index);
}
}
}
@dayneo
Copy link
Copy Markdown
Author

dayneo commented Feb 11, 2016

The current implementation will likely have many caveats, but it certainly gives us easy readonly indexer based access.

Simple set the CollectionViewType property on the CollectionViewSource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment