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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:56:42+00:00 2026-05-30T13:56:42+00:00

Is it possible to have a listbox (or another control that has a SelectedItem)

  • 0

Is it possible to have a listbox (or another control that has a SelectedItem) bound to a ICollectionView, displaying items like this :

  • Item1Name
  • Item2Name
  • ParentName1
    • Item3Name
    • Item4Name
  • ParentName2
    • Item5Name
    • Item6Name

The class used as a source for the CollectionViewSource’s view :

public class Item
{
    public string Name { get; set; }
    public string Parent { get; set; }
}

Item1 and Item2 have ParentName property set to null, Item3 and Item4 have “ParentName1” as ParentName property, and so on.

I really like the listbox approach because only items can be selected, groups are not selectable. But I may be going the wrong path.

  • 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-30T13:56:43+00:00Added an answer on May 30, 2026 at 1:56 pm

    Finally I implemented a style selector for setting group style if group is null :

    public class NullGroupStyleSelector : StyleSelector
    {
        public Style NullGroupStyle { get; set; }
        public Style DefaultStyle { get; set; }
    
        public override Style SelectStyle(object item, DependencyObject container)
        {
            var element = container as FrameworkElement;
            var group = item as CollectionViewGroup;
    
            if (element != null && group != null && group.Name == null)
            {
                return this.NullGroupStyle;
            }
    
            return this.DefaultStyle;
        }
    }
    

    and group styles with templates :

    <Style TargetType="{x:Type GroupItem}" x:Key="NoGroupHeaderStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GroupItem}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
    
                        <Border Grid.Row="0">
                            <!-- group name -->
                        </Border>
    
                        <ItemsPresenter Grid.Row="1" Margin="20,0,0,0" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListBox control, that contains a few items that display attachments (files
I have a listbox that has the following items and values right now. Items,
is it possible to have specific text in a listbox line to act like
I have a listbox that has its SelectionMode property set to Multiple. Is it
I have a Listbox that allows user to select multiple items. Normally user can
I have a user control that inherits from the ListBox class and displays a
I am creating a timeline control that uses listbox to place my items on
Is it possible to have a ListBox with a Data Template that changes depending
I have a ListBox containing CheckBoxes. Xaml looks like this: <ListBox x:Name=lbContactTypes> <ListBox.ItemTemplate> <HierarchicalDataTemplate>
Hei, So lets assume that I have this ListBox.ItemTemplate: <phone:PhoneApplicationPage.Resources> <DataTemplate x:Key=DataTemplate1> <StackPanel Orientation=Horizontal>

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.