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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:18:41+00:00 2026-05-20T10:18:41+00:00

I need a listbox that selects on first click and un-selects on second click,

  • 0

I need a listbox that selects on first click and un-selects on second click, so that only zero or one item is selected at any time.

The select/unselect is implemented in the listbox (with SelectionMode=”Single”) when you hold down crtl, but unfortunately, none of my users can be expected to know that.

With SelectionMode=”Multiple” we have the exact functionality I want, except that you can select more than one item…

More background:
I want the user to first choose which installation to log into, then to give credentials (and some other choices)

To achieve this I have used a listbox with expanding content. To aid the expansion I have on the left side of the listboxitem made a triangle that points right when unexpanded that turns to point down when you have selected the listbox item.

So, first the user see the list over the installations, and then, when he has chosen the item he wants by selecting it, the listboxitem expands to the rest of the info he need to enter. It’s quite nice, and works well, but testing reports that they want a second click to the triangle to unselect (and thus collapse the expanded section). And I must admit that I have clicked the ¤%& arrow too, expecting the action to result in a collapse… 🙁

Anyone has an idea how this can be achieved (preferably without code behind)?

  • 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-20T10:18:42+00:00Added an answer on May 20, 2026 at 10:18 am

    try that:

    you use a ToggleButton as the “Expander” of the detailed content.
    The “IsChecked” Property of the toggle Button you can bind to the IsSelected Property of the item

    here the code:

    <ListBox SelectionMode="Single">
       <ListBox.ItemsSource>
          <x:Array Type="{x:Type sys:String}">
             <sys:String>test1</sys:String>
             <sys:String>test2</sys:String>
             <sys:String>test3</sys:String>
             <sys:String>test4</sys:String>
             <sys:String>test5</sys:String>
             <sys:String>test6</sys:String>
          </x:Array>
       </ListBox.ItemsSource>
       <ListBox.ItemTemplate>
          <DataTemplate>
             <StackPanel Orientation="Horizontal">
                <ToggleButton IsChecked="{Binding 
                              RelativeSource={RelativeSource FindAncestor, 
                              AncestorType={x:Type ListBoxItem}},
                              Path=IsSelected}"
                >btn</ToggleButton>
             </StackPanel>
          </DataTemplate>
       </ListBox.ItemTemplate>
    </ListBox>
    

    how it works:
    In the Listbox can only one item be selected. As we select an item the Toggler gets expanded cause his IsChecked is bound to ListBoxItem.IsSelected (ListBoxItem is a Control which gets wrapped around the Content of each Item) of his parent ListBoxItem.
    As the selectionMode is single as soon as another item gets selected the following happens:

    • Deselect the actually selected item
    • Through the binding the Toggler gets unchecked too
    • Select the new item
    • the New items toggler gets checked through its binding

    and if just the actually selected item’s toggler gets unchecked the item deselects itself through the binding…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to an expression that returns only things with an I followed by either
I need to change the DataTemplate for items in a ListBox depending on whether
I need to allow the vertical scrollbar in a multiselect listbox (VB6) however, when
Need a function that takes a character as a parameter and returns true if
Need a way to allow sorting except for last item with in a list.
Need a function like: function isGoogleURL(url) { ... } that returns true iff URL
Need to locate the following pattern: The letter I followed by a space then
need ask you about some help. I have web app running in Net 2.0.
I need to know about Epoll On linux System. Could you recommend manual or
I need to copy hundreds of gigs of random files around on my computer

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.