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

  • Home
  • SEARCH
  • 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 4053764
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:29:19+00:00 2026-05-20T14:29:19+00:00

Given a list of objects containing two properties (IdentityType and Name) in the format:

  • 0

Given a list of objects containing two properties (IdentityType and Name) in the format:

IdentityType | Name
A | One  
A | Two  
A | Three  
B | Four  
B | Five  
C | Six  

Is there a way to declaratively databind that so the accordion displays like this?

A
- One
- Two
- Three
B
- Four
- Five
C
- Six

So far the best I can get is a panel header for each item, like so:

<toolkit:Accordion ItemsSource="{Binding Path=Identities}" Grid.Row="2" SelectionMode="ZeroOrMore">
        <toolkit:Accordion.ItemTemplate>
            <DataTemplate >
                <TextBlock Text="{Binding IdentityType, Converter={StaticResource EnumDescriptionConverter}}"/>
            </DataTemplate>
            </toolkit:Accordion.ItemTemplate>
            <toolkit:Accordion.ContentTemplate>
            <DataTemplate>
                <StackPanel Margin="5" Orientation="Horizontal">
                    <TextBlock Text="{Binding Name}" Foreground="White" />
                </StackPanel>
            </DataTemplate>
        </toolkit:Accordion.ContentTemplate>
    </toolkit:Accordion>

I’m new to Silverlight so I could be missing something blindingly obvious, but any help would be very much appreciated!

  • 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-20T14:29:19+00:00Added an answer on May 20, 2026 at 2:29 pm

    You can do this with a view model inbetween your model (the initail list) and your view (the markup).

    • Create a view model class with a Title and a NameCollection
    • Use LINQ (or a simple foreach) to translate your existing list of 6 entities to a list of 3 entites with 3, 2 and 1 Names in their name collection respectively.
    • Bind your Accordions ItemsSource to the collection of ViewModel objects.
    • Bind the text block in the your accordion items header template to your Title property
    • Add a repeating item control like ItemsControl to your content template of your accordion item
    • Bind your repeating item to the NamesCollection

    Assuming your model is as follows…

    public class Model
    {
        public string Title { get; set; }
        public string Name { get; set; }
    }
    

    Your View Model structure should be…

    public class ViewModel
    {
        public string Title { get; set; }
        public List<string> Names { get; set; }
    }
    
    public class DataContextClass
    {
        public DataContextClass()
        {
            var modelData = new ModelData();
    
            var query = from m in modelData.ModelCollection
                        group m by m.Title
                        into vm select new ViewModel { Title = vm.Key, Names = vm.Select(x => x.Name).ToList() };
            ViewModelCollection = query.ToList();
        }
    
        public List<ViewModel> ViewModelCollection { get; set; }
    }
    

    Then your view can create an instance of your DataContextClass, assign it to it’s own DataContext property and then use this markup…

    <layout:Accordion ItemsSource="{Binding Path=ViewModelDataInstance.ViewModelCollection}" >
        <layout:Accordion.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Title}" />
            </DataTemplate>
        </layout:Accordion.ItemTemplate>
        <layout:Accordion.ContentTemplate>
            <DataTemplate>
                <ItemsControl ItemsSource="{Binding Path=Names}" />
            </DataTemplate>
        </layout:Accordion.ContentTemplate>
    </layout:Accordion>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Starting with a list of objects containing two parameters notional and currency, how can
I have a List<> of objects containing two strings and a DateTime. I want
Given a list of objects, I am needing to transform it into a dataset
Given a Generic List of objects that contain a member variable that is a
Given a list, how would I select a new list, containing a slice of
Given a List<T> in c# is there a way to extend it (within its
I have a List object being accessed by multiple threads. There is mostly one
Given a List of MyClass objects (and a custom Comparitor myComparitor if needed), what
Let's say I have an unsorted list of four objects: [B, C, A, D]
I've got a System.Generic.Collections.List(Of MyCustomClass) type object. Given integer varaibles pagesize and pagenumber, how

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.