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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:24:03+00:00 2026-05-28T03:24:03+00:00

I am using manual limit of ListBox selected items to 5. I tried different

  • 0

I am using manual limit of ListBox selected items to 5.

I tried different approaches including some solution applied in some other related issue but still can’t make it.

I already tried: this but I cannot follow using “…attach onto the SelectionChanged event”. I mean how to do that?

this :but it clears all the selected items leaving no selected items.

and even setting the .SelectedIndex to -1 or null and the same thing happened. It deselected every selected items.

etc…

All I want to do is just to deselect(hope this make sense) the last selected item once the limitation is met.

Or worst solution : Can I disable my ListBox but still displaying the selected items(meaning still highlighted)?

I tried most if in the SelectionChanged and some on Mouse_Down Event

  • 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-28T03:24:04+00:00Added an answer on May 28, 2026 at 3:24 am

    If you follow the answer you linked to then you arrive at something like this:

    XAML

    <ListBox x:Name="myListBox" SelectionChanged="myListBox_SelectionChanged" SelectionMode="Multiple">
    ...
    </ListBox>
    

    Code behind

    void myListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // remove items from the end until at most 5 items are in the list
        while (myListBox.SelectedItems.Count > 5)
        {
            myListBox.SelectedItems.RemoveAt(SelectedItems.Count - 1);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pulling my hair out on this. I do some manual deserialization using XmlReader
How to do this using standard methods (without manual iteration through source string)? PS:
I'm using the popover object from Twitter's Bootstrap library in manual mode and I
Im using a linux machine, and I followed the instructions seen on https://www.php.net/manual/en/install.php to
The php.net page here http://www.php.net/manual/en/mysqlinfo.library.choosing.php says this Configure commands for using mysqlnd // Recommended,
I'm running a SQL server and need to run some commands using the SELECT
I have a pretty simple scenario using manual data operations with rad list view.
Is there a way to search a manual index in Neo4j using a numeric
been recoding my site using code igniter. I am having some quirks with my
I've been testing a database in MySQL for several months using manual deletes, updates,

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.