ComponentOne Basic Library for UWP
Basic Library Overview / CollectionView for UWP / Getting Started with C1CollectionView / C1CollectionView Versus CollectionViewSource
In This Topic
    C1CollectionView Versus CollectionViewSource
    In This Topic

    The standard ICollectionView interface and CollectionViewSource implementations in UWP are limited compared to WPF and Silverlight. For instance, the UWP implementation of ICollectionView does not support sorting, filtering or collection editing. The C1CollectionView class adds these missing elements so you can achieve that extra functionality you need. The IC1CollectionView interface is based on the WPF and Silverlight ICollectionView, so if you are familiar with those platforms, you will be familiar with sorting, filtering and grouping with C1CollectionView. If you are familiar with the CollectionViewSource class then moving to C1CollectionView is very easy.

    Take a look at this example binding the C1FlexGrid control to a CollectionViewSource versus a C1CollectionView given the same underlying list of Customer objects.

    CollectionViewSource:

    Visual Basic
    Copy Code
    Dim customers As List(Of Customer) = Await GetCustomerData()
    Dim view = New CollectionViewSource()
    view.Source = customers
    c1FlexGrid1.ItemsSource = view.View
    

    C#
    Copy Code
    List<Customer> customers = await GetCustomerData();
    var view = new CollectionViewSource();
    view.Source = customers;
    c1FlexGrid1.ItemsSource = view.View;
    

    C1CollectionView:

    Visual Basic
    Copy Code
    Dim customers As List(Of Customer) = Await GetCustomerData()
    Dim view = New C1.Xaml.C1CollectionView(customers)
    c1FlexGrid1.ItemsSource = view
    

    C#
    Copy Code
    List<Customer> customers = await GetCustomerData();
    var view = new C1.Xaml.C1CollectionView(customers);
    c1FlexGrid1.ItemsSource = view;
    

    If you are working in MVVM, simply expose a property of type IC1CollectionView on the view model and populate the collection within the view model. Then bind the ItemsSource property of C1FlexGrid (or whatever control you are using) to the property in XAML.

    Visual Basic
    Copy Code
    ''' <summary>
    ''' Gets the collection of customers.
    ''' </summary>
    Public ReadOnly Property Customers() As C1.Xaml.IC1CollectionView
          Get
                Return view
          End Get
    End Property
    

    C#
    Copy Code
    /// <summary>
    /// Gets the collection of customers.
    /// </summary>
    public C1.Xaml.IC1CollectionView Customers
    {
        get { return view; }
    }
    
    See Also