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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:44:05+00:00 2026-06-14T05:44:05+00:00

I have a DataGrid like this: class SearchFile { public string path { set;

  • 0

I have a DataGrid like this:

    class SearchFile
    {
        public string path { set; get; }
        public int count { set; get; }
    }

   //...

        files = new List<SearchFile>();

        DataGridTextColumn col1 = new DataGridTextColumn();
        DataGridTextColumn col2 = new DataGridTextColumn();
        col1.Header = "File";
        col2.Header = "count";
        col1.Binding = new Binding("path");
        col2.Binding = new Binding("count");
        dataGrid1.Columns.Add(col1);
        dataGrid1.Columns.Add(col2);

I do this to populate the items source:

            foreach(var file in allFiles)
            {
                SearchFile sf = new SearchFile() { path=file, count=c };
                files.Add(sf);
            }

The above is a part of an event handler that will be launched multiple times. Where do I bind the files to the ItemsSource property so that it’s dynamically updated? I tried putting it after the foreach loop, but only the first run has any effect and the grid doesn’t change on subsequent runs (when allFiles is different).

  • 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-14T05:44:06+00:00Added an answer on June 14, 2026 at 5:44 am

    Use an ObservableCollection. It provides notifications when items get added, removed, or when the whole list is refreshed:

    files = new ObservableCollection<SearchFile>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object model like this: class Car { public string Manufacturer; public
Say I have a class like this: public class MyClass { public string Name;
I am new to Flash and AS3. I have a DataGrid like this Item
I've a List<DetailObject> someList; which looks like this: public class DetailObject { public string
I have a class like this to be bind to a datagrid as itemsource:
I have a class defined like this: class TouchScreenDisabledGrid:DataGrid,INotifyPropertyChanged I want to change soome
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public
I have an object that looks like this: [Bindable] public class MyRecord implements ValueObject
I have a datagrid like this: <dg:DataGrid Name=dg AutoGenerateColumns=False CanUserDeleteRows=True> <dg:DataGrid.Columns> <dg:DataGridTextColumn Header=Product Code
I have the following data structures class Car { int CarID; string CarModel; string

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.