Click here to Skip to main content
15,891,204 members
Articles / Mobile Apps / Windows Phone 7

RegiRide, a complete Windows Phone application

Rate me:
Please Sign up or sign in to vote.
4.99/5 (51 votes)
24 Jun 2012CPOL17 min read 114K   2.5K   123  
A complete WP7 application with SQL compact database, LINQ to SQL, MVVM Light and Dropbox integration
using System;

namespace RegiRide.Utils
{
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;

    public class LongListCollection<T, TKey> : ObservableCollection<LongListItem<T, TKey>> where T : IComparable<T>
    {
        public LongListCollection()
        {
        }

        public LongListCollection(IEnumerable<T> items, Func<T, TKey> keySelector)
        {
            if (items == null)
            {
                throw new ArgumentException("items");
            }

            var groups = new Dictionary<TKey, LongListItem<T, TKey>>();

            foreach (var item in items.OrderBy(x => x))
            {
                var key = keySelector(item);

                if (groups.ContainsKey(key) == false)
                {
                    groups.Add(key, new LongListItem<T, TKey>(key));
                }

                groups[key].Add(item);
            }

            foreach (var value in groups.Values)
            {
                this.Add(value);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect http://www.simpletechture.nl
Netherlands Netherlands
Patrick Kalkman is a senior Software Architect with more than 20 years professional development experience. He works for SimpleTechture where he helps teams develop state of the art web applications.

Patrick enjoys writing his blog. It discusses agile software development. Patrick can be reached at patrick@simpletechture.nl.

Published Windows 8 apps:


Published Windows Phone apps:


Awards:

Best Mobile article of March 2012
Best Mobile article of June 2012

Comments and Discussions