Can a ListBox have headers?

10 posts, 1 answers
  1. Rod
    Rod avatar
    71 posts
    Member since:
    Jan 2011

    Posted 13 Mar 2013 Link to this post

    I'm working with my first RadListBox in WPF. Can it have headers? If so, how is that done?
  2. Answer
    Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 18 Mar 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Rod
    Rod avatar
    71 posts
    Member since:
    Jan 2011

    Posted 18 Mar 2013 Link to this post

    It is what it is, we'll wait.
  5. Vaidas
    Vaidas avatar
    2 posts
    Member since:
    May 2015

    Posted 28 Jul 2015 in reply to Rod Link to this post

    Hello, any news about RadListBox headers?
  6. Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 30 Jul 2015 Link to this post

    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
  7. Stephen
    Stephen avatar
    17 posts
    Member since:
    Aug 2013

    Posted 17 Dec 2015 in reply to Nasko Link to this post

    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...
  8. Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 18 Dec 2015 Link to this post

    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
  9. Stephen
    Stephen avatar
    17 posts
    Member since:
    Aug 2013

    Posted 18 Dec 2015 in reply to Nasko Link to this post

    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...

  10. Stephen
    Stephen avatar
    17 posts
    Member since:
    Aug 2013

    Posted 21 Dec 2015 in reply to Nasko Link to this post

    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"...
  11. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 22 Dec 2015 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready