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 342971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:51:14+00:00 2026-05-12T10:51:14+00:00

Now I am aware that I probably need to use a ListBox and can

  • 0

Now I am aware that I probably need to use a ListBox and can use the GroupStyle stuff which completely 100% fits my needs. Only thing is that I’ve been told that:

“Whenever a “GroupStyle” is set on the control, the panel that layouts the items changes from VirtualizingStackPanel to StackPanel (this is a hack in MS code)…”

I will need to display up to 2000 tracks using this mecahnism:

1) Does this bug still exist?

2) Is this something to worry about for up to 2000 tracks? (More like an average of 50-100)

Also, the group by will not be changed by the user. The tracks will be grouped the same way throughout the duration of the control.

  • 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-12T10:51:14+00:00Added an answer on May 12, 2026 at 10:51 am

    As far as I know, ListBox still stops virtualisation of items when groups are applied.

    Whether 2000 items would perform adequately will depend upon the complexity of the template applied to each item. I have a ListBox with a relatively simple template (about 8 TextBlocks in a horizontal StackPanel) and performance starts to degrade at around 1500 items with grouping applied. It also seems to depend upon the number of groups into which the items are aggregated, where a greater number of groups results in less performance. This is especially noticeable when scrolling for some reason.

    ListBox makes dynamic grouping very easy, but if you’re usually going to be grouping by album then it might be better to set the ItemsSource of your ItemsControl (maybe a ListBox) to be a collection of Album objects, each of which has a Tracks property that is itself a collection of Track objects. Assuming this, I see two options:

    1. Use nested ItemsControls in the Album DataTemplate
    2. Use a HeaderedItemsControl such as TreeView with a HierarchicalDataTemplate

    In option one, you have to manage the selection manually. You could, in the simplest implementation, have the ability to select albums and tracks separately; potentially having a track selected that didn’t belong to the selected album. You may be able to do without selection of an album as this isn’t a concept present in the track-list view of other media players I can think of.

    Solution one also has implications for keyboard navigation from the last track of one album to the first track of the next album.

    Assuming the following code:

    public class Album
    {
        public string Title { get; set; }
        public ObservableCollection<Track> Tracks { get; set; }
    }
    
    public class Track
    {
        public string Title { get; set; }
    }
    
    _tracks.ItemsSource = new[] {
        new Album { 
            Title = "Album 1",
            Tracks = new ObservableCollection<Track> {
                new Track { Title = "Track 1" },
                new Track { Title = "Track 2" }
            }
        },
        new Album { 
            Title = "Album 2",
            Tracks = new ObservableCollection<Track> {
                new Track { Title = "Track 1" },
                new Track { Title = "Track 2" }
            }
        }
    };
    

    Here’s some code that demonstrates option one:

    <ListBox x:Name="_tracks">
        <FrameworkElement.Resources>
            <DataTemplate DataType="{x:Type local:Track}">
                <TextBlock Text="{Binding Path=Title}" />
            </DataTemplate>
            <DataTemplate DataType="{x:Type local:Album}">
                <StackPanel>
                    <TextBlock Text="{Binding Path=Title}" />
                    <ListBox ItemsSource="{Binding Path=Tracks}" />
                </StackPanel>
            </DataTemplate>
        </FrameworkElement.Resources>
    </ListBox>
    

    Change the outer ListBox to an ItemsControl to alleviate the selection issue, as discussed. You’ll have to make it look pretty though as the above looks pretty ugly.

    Option two could be defined like this:

    <TreeView x:Name="_tracks2">
        <FrameworkElement.Resources>
            <DataTemplate DataType="{x:Type local:Track}">
                <TextBlock Text="{Binding Path=Title}" />
            </DataTemplate>
            <HierarchicalDataTemplate DataType="{x:Type local:Album}"
                                      ItemsSource="{Binding Path=Tracks}">
                <TextBlock Text="{Binding Path=Title}" />
            </HierarchicalDataTemplate>
        </FrameworkElement.Resources>
    </TreeView>
    

    ListView supports opt-in UI virtualisation as of 3.5SP1 via the XAML attribute:

    VirtualizingStackPanel.IsVirtualizing="True"
    

    Bea Stollnitz has three great posts on this topic, though as she points out they’re out of date since SP1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By now most folks on this site are probably aware that: $("#someTable TD.foo").click(function(){ $(e.target).doSomething();
Now, I am aware that there is no such thing as exiting an app
Now I'm sure we're all well aware of the relative merits of Linux vs
I'm aware of server-side javascript for a long time now, but I don't have
Now I use the websphere MQ client connect to remote MQ Server(7.0 version) using
Now that most of the major browsers support full page zoom (at present, the
Now that I know C++ I want to get into desktop application that have
Now that LINQ to SQL is a little more mature, I'd like to know
Now that .NET v3.5 SP1 has been released (along with VS2008 SP1), we now
I have a view spec that was passing but is broken now that pagination

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.