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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:54:24+00:00 2026-05-22T19:54:24+00:00

A known issue with nesting ListBoxes in a Windows Phone 7 App is that

  • 0

A known “issue” with nesting ListBoxes in a Windows Phone 7 App is that for each parent category their respective child ListBox retains its own SelectedItems list. Well, I have a situation where this is expected behavior, but I’m having issues capturing both the Parent and Child ListBox selected lists.

Current Functionality:
1. List item
2. List item
3. Loading of Parent and Child ListBox data is working
4. Multi-select of Parent ListBox items works prefectly
5. Multi-select of Child ListBox items works, but is not accessible
6. Multi-select of Child ListBox items for a number of different parents works in the UI, but the selection is lost when scrolling large list sets and is not accessible
7. lstCategory is accessible directly, but lstSubCategory is not accessible directly (possibly, I just don’t know how)
8. I’m bound to a ViewModel with one complex object that represents the two ListBoxes as two List objects.

Expected Functionality:
I would like to be able to select both Category (parent) and SubCategory (child) ListBox items as follows; (X) Denotes Selected:

  • Bread (X)
    • Loaf (X)
    • Croissant
    • Buscuit (X)
    • Donut
  • Fruit
    • Pinaple (X)
    • Strawberry
  • Drinks (X)
    • Water
    • Milk (X)
    • Juice (X)
    • Soda
  • Snacks (X)
    • Chips
    • Fries
    • Trail Mix

I would like to retain the selections even if this was a long list. So, what I want to capture and work with is:

  • Bread (X)
  • Loaf (X)
  • Buscuit (X)
  • Pinaple (X)
  • Drinks (X)
  • Milk (X)
  • Juice (X)
  • Snacks (X)

Since I have a CategoryID in each of the items’ objects, I can strip the heirarchy information on capture.

For breivity, here is the essence of the code:

        <ListBox 
            x:Name="lstCategory"
            SelectionMode="Multiple" 
            ItemsSource="{Binding Categories}" 
            FontSize="32" 
            Margin="0,0,0,67">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding CategoryName}"
                                        FontSize="36"
                                        TextWrapping="Wrap"
                                        Margin="20,0,0,0"
                                        VerticalAlignment="Top"/>
                            <StackPanel  Orientation="Vertical" Margin="60,0,0,0">
                                <ListBox
                                    x:Name="lstSubCategory"
                                    SelectionMode="Multiple" 
                                    ItemsSource="{Binding SubCategories}">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding SubCategoryName}"
                                                       FontSize="28"
                                                       TextWrapping="Wrap"
                                                       VerticalAlignment="Top"/>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

And the ViewModel:

    public List<Category> Categories { get; set; }

    public PostCategorySelectVM()
    {
        Categories = new List<Category>()
        {
            new Category() 
            { 
                CategoryID = 0, 
                CategoryName = "Bread",
                SubCategories = new List<SubCategory>()
                {
                    new SubCategory() {
                        CategoryID = 001,
                        SubCategoryName = "Loaf"
                    },
                    new SubCategory() {
                        CategoryID = 002,
                        SubCategoryName = "Croissant"
                    }
                    // ...
                }
                // ...
            }
            // ...
        }
    }

Category Class:

public class Category
{
    public int CategoryID { get; set; }
    public string CategoryName { get; set; }
    public List<SubCategory> SubCategories { get; set; }
}

SubCategory Class:

public class SubCategory
{
    public int CategoryID { get; set; }
    public string SubCategoryName { get; set; }
}

Save Button Click Event:

    private void btnSave_Click(object sender, RoutedEventArgs e)
    {
        foreach (Category item in lstCategory.SelectedItems)
        {
            catList.Add(item);
        }

        foreach (Category cat in catList)
        {
            scatList = cat.SubCategories;
            foreach (SubCategory scat in scatList)
            {
                // How do I select the "Selected" SubCategories?
                // How do I select the lstSubCategory control?
            }
        }
    }

Final Notes:

  • The only lead I have has do do with dependancy properties, but the only examples I’ve seen require the FrameworkPresentation.dll which is not available on WP7.
  • The nested ListBox has the expected UI functionality (except for large lists removing cross-selections on scroll)
  • The user experience feels best when both Category and SubCategory are shown on the same screen.
  • Consider the UI functionality like a directory search engine. You may want to select the general category and/or the sub categories in different combinations, but the parent should not require a child and a child should not require a parent, yet both child and parent could exist (for specificity).
  • 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-22T19:54:25+00:00Added an answer on May 22, 2026 at 7:54 pm

    You could use checkboxes instead of textboxes in your data templates, and then bind the IsChecked property of the checkboxes to an IsSelected property in your Category/Subcategory classes:

        <ListBox x:Name="lstCategory"
            ItemsSource="{Binding Categories}" 
            FontSize="32" 
            Margin="0,0,0,67">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <CheckBox Content="{Binding CategoryName}"
                                    FontSize="36"
                                    IsChecked="{Binding IsSelected,Mode=TwoWay}"
                                    Margin="20,0,0,0"
                                    VerticalAlignment="Top"/>
                        <ListBox ItemsSource="{Binding SubCategories}" Margin="60,0,0,0">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Content="{Binding SubCategoryName}"
                                                FontSize="28"
                                                IsChecked="{Binding IsSelected,Mode=TwoWay}"
                                                VerticalAlignment="Top"/>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    

    You should also have your category/subcategory classes implement INotifyPropertyChanged to properly fire notifications when IsSelected is set.

    assuming that, your save would look something like (this isnt’ exact!)

    private void btnSave_Click(object sender, RoutedEventArgs e)
    {
        catList.Clear();
        catList.AddRange( lstCategory.Items.OfType<Category>().Where(x=>x.IsSelected));
    
        scatList.Clear();
        foreach (Category cat in catList)
        {
            scatList.AddRange(cat.SubCategories.Where(x=>x.IsSelected));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if this is a known issue that I am running into,
Am I doing something wrong is this a known issue with the ASP.NET MVC
Are there any known issues with canceling HttpWebRequest HTTP requests? We find that when
Is this a known issue? I have the following XAML: <Grid x:Name=LayoutRoot> <Popup> <Slider
this is a known issue with ItemsControl although I couldn't find a solution :(
There is a known issue with Safari and Chrome, when you can't pass a
It's a well known issue this damn error expected class-name before ‘{’ token Well,
I know this is a known issue. But I've tried everything I found out
I just want to know if there is any known issue, or if I'm
There is a known issue with using jquery fadeOut, fadeIn, and fadeToggle, when fading

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.