This is a migrated thread and some comments may be shown as answers.

Can a ListBox have headers?

9 Answers 223 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Rod
Top achievements
Rank 1
Rod asked on 13 Mar 2013, 09:01 PM
I'm working with my first RadListBox in WPF. Can it have headers? If so, how is that done?

9 Answers, 1 is accepted

Sort by
0
Accepted
Boyan
Telerik team
answered on 18 Mar 2013, 12:21 PM
Hello Rod,

This can be achieved with RadListbox using CollectionViewSource. Unfortunately this scenario is not working with the latest release of our controls. We will try to fix the problem for the SP, which is scheduled for the beginning of next month. Hope this timeframe is acceptable for you.

I have attached a sample project that shows the approach, but notice that it will throw error when selecting items from different groups.

All the best,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Rod
Top achievements
Rank 1
answered on 18 Mar 2013, 08:20 PM
It is what it is, we'll wait.
0
Vaidas
Top achievements
Rank 1
answered on 28 Jul 2015, 07:49 AM
Hello, any news about RadListBox headers?
0
Nasko
Telerik team
answered on 30 Jul 2015, 02:36 PM
Hello Vaidas,

The approach that we could suggest you to use in order to achieve the desired is the one proposed by Boyan below -  to use CollectionViewSource. The issue that was previously observed is already fixed.

Please, check the attached sample using the latest official released version Q1 2015 SP and let us know if that is what you are looking for.

Hopes this helps.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stephen
Top achievements
Rank 1
answered on 17 Dec 2015, 05:56 PM
Is there some reason this would not entirely work within a UserControl? I was able to do everything in the example except that my group headers are blank, i.e. all the player names show up, but the Club does not. There is actually an empty row displaying, but not the Club...
0
Nasko
Telerik team
answered on 18 Dec 2015, 12:53 PM
Hi Stephen,

We tested the sample in a UserControl and it seems everything is working as expected on our side. Please, check if the HeaderTemplate of the group is applied as expected - if it is not the observed blank space could be displayed. Check the attached video that demonstrates how the sample is working on our side and how the issue could be reproduced if the HeaderTemplate is not applied as expected.

If that does not help please, send us a sample that reproduces the issue - thus we could provide you with a prompt solution.

Hope this helps.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Stephen
Top achievements
Rank 1
answered on 18 Dec 2015, 05:41 PM

I think the HeaderTemplate is applied. I pretty much copied the original project - I have attached mine, only the name have been changed to protect the innocent!
:-)
It's interesting everything seems to be there except the actual club name...by that I mean the players (associates in my case) are being sorted and broken into groups exactly as they should...

just tried to attach file, but it says only jpg, jpeg, gif, or png...

0
Stephen
Top achievements
Rank 1
answered on 21 Dec 2015, 08:38 PM

I found my issue i in the code block:

<DataTemplate x:Key="groupTemplate">
            <StackPanel Orientation="Horizontal" Background="Aquamarine">
                <TextBlock Text="{Binding Name}"  />
            </StackPanel>
        </DataTemplate>

"Name" appears to be some other property than the the property associated with the Player class, i.e. I thought it was supposed to match the property in the following code block:

<telerik:RadListBox.ItemTemplate>
                <DataTemplate>
                    <VirtualizingStackPanel>
                        <TextBlock Text="{Binding Name}" />
                    </VirtualizingStackPanel>
                </DataTemplate>
            </telerik:RadListBox.ItemTemplate>

As it turns out, the property I was using in the ItemTemplate was "display", and that's what I was also "matching" up in the groupTemplate. It seems that the property in the groupTemplate should always be "Name"...
0
Kalin
Telerik team
answered on 22 Dec 2015, 07:52 AM
Hello Stephen,

We are glad you have managed to achieve the desired. If you have any other questions, please let us know.

Regards,
Kalin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListBox
Asked by
Rod
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Rod
Top achievements
Rank 1
Vaidas
Top achievements
Rank 1
Nasko
Telerik team
Stephen
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or