Created
February 11, 2016 16:44
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.