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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:14:41+00:00 2026-06-01T11:14:41+00:00

Hi I am trying to update a listbox that’s bound after I delete a

  • 0

Hi I am trying to update a listbox that’s bound after I delete a folder but it doesn’t seem to update unless I go out of page and back can anyone help I have my code with class Project below, thanks for your help.

public partial class Page3 : PhoneApplicationPage
{
    string[] fileNames;
    string[] folderNames;
    private string selectedProject = "";


    private List<Project> projectList = new List<Project>();
    public Page3()
    {
        InitializeComponent();
        showProjects();

    }

    public void showProjects()
    {

        projectList.Clear();
        IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
        folderNames = isf.GetDirectoryNames("/*.*");

        foreach (var name in folderNames)
        {

            fileNames = isf.GetFileNames(name + "/*.*");
            int frameCount = 0;
            foreach (var nameCount in fileNames)
            {
                frameCount++;

            }



            projectList.Add(new Project(name,frameCount));

        }


        listBoxProjects.ItemsSource = projectList;

    }


    private void listBoxProjects_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {

    }


    public void DeleteDirectory(string directoryName)
    {
        try
        {
            IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
            if (!string.IsNullOrEmpty(directoryName) && myIsolatedStorage.DirectoryExists(directoryName))
            {
                myIsolatedStorage.DeleteDirectory(directoryName);
            }
        }
        catch (Exception ex)
        {
            // handle the exception
        }
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        IsolatedStorageFile myIso;
        string folder = textBoxDelete.Text;
        using (myIso = IsolatedStorageFile.GetUserStoreForApplication())
        {

            String[] fileNames = myIso.GetFileNames(folder + "/*.*");

            foreach (var name in fileNames)
            {
                MessageBox.Show(name);
                myIso.DeleteFile(folder + "/" + name);




            }




            myIso.DeleteDirectory(folder);
            showProjects();
        }




    }





}


public class Project
{
    public string ProjectName { get; set; }
    public int FileCount { get; set; }


    public Project(string pName, int fileCount)
    {
        this.ProjectName = pName;
        this.FileCount = fileCount;
    }



}

}

  • 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-01T11:14:42+00:00Added an answer on June 1, 2026 at 11:14 am

    You could try to set the listbox.Itemsource to null first and then reset it with the new collection.

    But i would suggest you that you put you change your List<> items to an ObservableCollection<> and then if you change the collection the changes are automatically updated in your listbox, and try using binding much easier and cleaner solution.

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

Sidebar

Related Questions

I am trying to make editable listbox that gives user ability to update listitem
I'm trying to write a page that filters a ListBox depending on the contents
I trying to update a model on a callback but the validation is causing
Im trying to update the contents of an element after running some php code.
I'm trying to update a hashtable in a loop but getting an error: System.InvalidOperationException:
I was trying to create a custom combobox that inherited from ComboBox, but I've
I'm trying to make a ListBox that updates to the contents of an ObservableCollection
I have a Crystal Report I'm trying to recreate from scratch after an update
I'm trying to create a custom ListBox. That receives a list with three properties:
I'm trying to use a ListBox.DataSource = ObservableCollection, however I can't figure out how

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.