Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:04:15+00:00 2026-05-31T03:04:15+00:00

I’d like to use a designer (e.g. Expression Blend) to template the LongListSelector control

  • 0

I’d like to use a designer (e.g. Expression Blend) to template the LongListSelector control (from the SL toolkit for WP7), but I can’t figure out how to format the data to fit what this control expects.

Any pointers to a tutorial would be appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:04:16+00:00Added an answer on May 31, 2026 at 3:04 am

    Use a specialized collection, like this:

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Linq.Expressions;
    using System.Collections.ObjectModel;
    
    namespace Stackoverflow.Collections
    {
        /// <summary>
        /// Represents a specialized collection to integrate with the 
        /// <see cref="Microsoft.Phone.Controls.LongListSelector"/> control.
        /// </summary>
        /// <typeparam name="T">The type of the values in the collection.</typeparam>
        /// <typeparam name="TKey">The type of the keys in the collection.</typeparam>
        public class LongListCollection<T, TKey> : ObservableCollection<LongListItem<T, TKey>>
            where T : IComparable<T>
            where TKey : IComparable<TKey>
        {
            /// <summary>
            /// The key selector for adding items.
            /// </summary>
            private Func<T, TKey> keySelector;
    
            /// <summary>
            /// Initializes a new instance of the <see cref="LongListCollection&lt;T, TKey&gt;"/> class.
            /// </summary>
            /// <param name="keySelector">The key selector.</param>
            public LongListCollection(Func<T, TKey> keySelector)
            {
                if (keySelector == null)
                    throw new ArgumentNullException("keySelector");
    
                this.keySelector = keySelector;
            }
    
            /// <summary>
            /// Initializes a new instance of the <see cref="LongListCollection&lt;T, TKey&gt;"/> class.
            /// </summary>
            /// <param name="keySelector">The key selector.</param>
            /// <param name="items">A initial collection.</param>
            public LongListCollection(Func<T, TKey> keySelector, IEnumerable<T> items)
            {
                if (keySelector == null)
                    throw new ArgumentNullException("keySelector");
    
                if (items == null)
                    throw new ArgumentNullException("items");
    
                this.keySelector = keySelector;
    
                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);
            }
    
            /// <summary>
            /// Adds the specified item to the collection.
            /// </summary>
            /// <param name="item">The item.</param>
            public void Add(T item)
            {
                TKey key = keySelector(item);
    
                var group = this.FirstOrDefault(x => x.Key.Equals(key));
                if (group != null)
                    group.Add(item);                
                else
                    this.Add(new LongListItem<T, TKey>(key) { item });
            }
    
            /// <summary>
            /// Inserts an item into the collection at the specified index.
            /// </summary>
            /// <param name="index">The zero-based index at which item should be inserted.</param>
            /// <param name="item">The object to insert.</param>
            protected override void InsertItem(int index, LongListItem<T, TKey> item)
            {
                for (int i = 0; i < this.Count; i++)
                {
                    switch (Math.Sign(this[i].CompareTo(item)))
                    {
                        case 0:
                            throw new InvalidOperationException("Cannot insert duplicated items.");
                        case 1:
                            base.InsertItem(i, item);
                            return;
                        case -1:
                            break;
                    }
                }
    
                base.InsertItem(this.Count, item);
            }
        }
    
        /// <summary>
        /// Represents a specialized data structure to integrate with the 
        /// <see cref="Microsoft.Phone.Controls.LongListSelector"/> control.
        /// </summary>
        /// <typeparam name="T">The type of the values in the structure.</typeparam>
        /// <typeparam name="TKey">The type of the key in the structure.</typeparam>
        public class LongListItem<T, TKey> : ObservableCollection<T>, IComparable<LongListItem<T, TKey>>
            where T : IComparable<T>
            where TKey : IComparable<TKey>
        {
            /// <summary>
            /// Initializes a new instance of the <see cref="LongListItem&lt;T, TKey&gt;"/> class.
            /// </summary>
            public LongListItem()
            {
            }
    
            /// <summary>
            /// Initializes a new instance of the <see cref="LongListItem&lt;T, TKey&gt;"/> class.
            /// </summary>
            /// <param name="key">The item's key.</param>
            public LongListItem(TKey key)
            {
                this.Key = key;
            }
    
            /// <summary>
            /// Gets or sets the item key.
            /// </summary>
            /// <value>The item key.</value>
            public TKey Key
            {
                get;
                set;
            }
    
            /// <summary>
            /// Gets a value indicating whether this instance has any items.
            /// </summary>
            /// <value><c>true</c> if this instance has any items; otherwise, <c>false</c>.</value>
            public bool HasItems
            {
                get
                {
                    return Count > 0;
                }
            }
    
            /// <summary>
            /// Inserts an item into the collection at the specified index.
            /// </summary>
            /// <param name="index">The zero-based index at which item should be inserted.</param>
            /// <param name="item">The object to insert.</param>
            protected override void InsertItem(int index, T item)
            {                              
                for (int i = 0; i < this.Count; i++)
                {
                    switch (Math.Sign(this[i].CompareTo(item)))
                    {
                        case 0:
                            return;
                        case 1:
                            base.InsertItem(i, item);
                            return;
                        case -1:
                            break;
                    }
                }
    
                base.InsertItem(this.Count, item);
            }
    
            /// <summary>
            /// Compares to.
            /// </summary>
            /// <param name="other">The other.</param>
            /// <returns></returns>
            public int CompareTo(LongListItem<T, TKey> other)
            {
                if (other == null)
                    return 1;
    
                return this.Key.CompareTo(other.Key);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I would like to count the length of a string with PHP. The string
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.