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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:10:12+00:00 2026-06-02T06:10:12+00:00

I am wondering why my selection index changed is firing twice when I click

  • 0

I am wondering why my selection index changed is firing twice when I click on an item on my list.

This is the code I use in the selectionindexchanged

 private void listBoxFolders_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // Taking the name of the folder to pass in the parameters
        if ((Folder)listBoxFolders.SelectedItem != null)
        {
            folderTmp = (Folder)listBoxFolders.SelectedItem;
        }

        // Connection to the webservice to get the subfolders and also the files
        WebClient wc = new WebClient();
        wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted2);
        wc.DownloadStringAsync(new Uri("http://clients.uicentric.net/IISHostedCalcService/FilesService.svc/GetFoldersAndFiles?selectedFolder=" + folderTmp.Name));
    }

and this is the method which is firing twice inside it:

 public void wc_DownloadStringCompleted2(object sender, DownloadStringCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);
            XNamespace aNamespace = XNamespace.Get("http://schemas.datacontract.org/2004/07/System.IO");

            try
            {

                // Retrieving the subfolders
                var folders = from query in xdoc.Descendants(aNamespace.GetName("DirectoryInfo"))
                              select new Folder
                              {
                                  Name = (string)query.Element("OriginalPath"),
                              };

                _lFolders = new ObservableCollection<Folder>();

                foreach (Folder f in folders)
                {
                    LFolders.Add(f);
                }

                listBoxFolders.ItemsSource = LFolders;
                listBoxFolders.DisplayMemberPath = "Name";


                // Retrieving the files
                var files = from query in xdoc.Descendants(aNamespace.GetName("FileInfo"))
                            select new File
                         {
                             Name = (string)query.Element("OriginalPath"),
                         };


                _lFiles = new ObservableCollection<File>();

                foreach (File f in files)
                {

                    LFiles.Add(f);
                }

                listBoxFiles.ItemsSource = LFiles;
                listBoxFiles.DisplayMemberPath = "Name";
                listBoxFiles.SelectionChanged += new SelectionChangedEventHandler(listBoxFiles_SelectionChanged);

            }
            catch { }

        }

    }
  • 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-02T06:10:13+00:00Added an answer on June 2, 2026 at 6:10 am

    You are reloading the item source of listbox upon the selection changed event. Becoause of the reload action, the index gets changed to its default value, ie, -1 .
    This probably must be your issue.
    Instead of using selection changed event go for Tap event.

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

Sidebar

Related Questions

I'm wondering why this code section prints out the following: print request.user.has_perm('bug_tracking.is_developer'): + str(request.user.has_perm('bug_tracking.is_developer'))
I was wondering if anyone could help me implement color selection in my iOS
I'm wondering how to change the blue highlight/selection color of a UITableViewCell , any
I have been wondering about the following lines of code [self performSelector:@selector(myMethod) withObject:self afterDelay:1.0];
I have this selector: $(table.details tbody tr:not(.details)) But I'm wondering why this inner table
Wondering what the best / good way of doing this would be in jQuery.
I was the Android Developer article on Search: http://developer.android.com/guide/topics/search/index.html and was wondering if I
I am wondering how those drag and drop widgets cancel text selection in the
I'm wondering how to create windows like these alt text http://img824.imageshack.us/img824/997/this.jpg I'm refering to
Just wondering what type of algorithm this is, or if there is an easier/more

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.