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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:23:52+00:00 2026-06-04T02:23:52+00:00

I have a question about Mvvmlight binding Listbox SelectedIndex. The full source code can

  • 0

I have a question about Mvvmlight binding Listbox SelectedIndex.
The full source code can be downloaded here.
Here is my precondition:

[TestModel]

string Title;
string Description;

[TestViewModel]

ObservableCollection<TestModel> TestList;

[xaml binding]

<ListBox ItemSource="{Binding TestList}"
         SelectedIndex="{Binding SelectedIndex Mode=TwoWay}">
       .....
       <i:EventTrigger EventName="SelectionChanged">
       .....
       </i:EventTrigger>.....

Here is my OnSelectionChanged code:

 private void OnSelectionChanged(TestModel test)
    {
        int index = SelectedIndex;
        Debug.WriteLine("[SelectionChanged] +++, index={0}", index);
        // If selected index is -1 (no selection) do nothing
        if (-1 == SelectedIndex)
            return;
        Debug.WriteLine("[SelectionChanged] selected item={0}", test.Title);
        // Reset selected index to -1 (no selection)
        SelectedIndex = -1;
        Debug.WriteLine("[SelectionChanged] ---, index={0}", index);
    }

I have a sample to have MainPage.xaml and TestPage.xaml.

  1. MainPage: This page has a button, click the button will navigate to TestPage
  2. TestPage: This page has a listbox and binding to ViewModel

When I run this sample, tap button to TestPage, and try to tap any item of Listbox, I can see the item has no focused color (because I reset SelectedIndex to -1).

Here comes the question, when I back to MainPage, then again tap button to TestPage, you will see tapping any item of Listbox will cause focused color on every item, it’s strange.

Hope anyone can help me to see if any problem on my sample.
Thanks.

  • 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-06-04T02:23:54+00:00Added an answer on June 4, 2026 at 2:23 am

    I got a workaround from somebody below:

    Change:

    <i:EventTrigger EventName="SelectionChanged">
    

    To:

    <i:EventTrigger EventName="Tap">
    

    It really works as what I expected.
    Tap can allow user to tap repeated ListItem, also “reset SelectedIndex = -1” can make selected item without highlight color.

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

Sidebar

Related Questions

I have question about my code which does the Hoare Partition Method. Here is
I have a question about JSF and GET http request. How can I get
Have a question about the design/usage of asp.net mvc here. In the html helper
I have question about throw. How will the throw work in the following code?
I have question about Dictionaries in Python. here it is: I have a dict
Have a question about VBS: How can i start a new window (e.g. of
I'm learning asp.net. I have question about example buttons I can use two types
Have a question about full text search. I have a query that works, but
https://stackoverflow.com/a/64983/468251 - Hello, I have question about this code, how made that working with
I have a question about this code: typedef struct pop { unsigned long int

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.