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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:24:09+00:00 2026-05-12T16:24:09+00:00

I have created WPF MVVM application, and set WPFToolkit DataGrid binding to DataTable so

  • 0

I have created WPF MVVM application, and set WPFToolkit DataGrid binding to DataTable so I want to know how to implement DataTable property to notify changed. Currently my code is like below.

public DataTable Test
{
    get { return this.testTable; }
    set 
    { 
        ...
        ...
        base.OnPropertyChanged("Test");
    }
}

public void X()
{
    this.Test.Add(...); // I suppose this line will call to getter first (this.Test = get Test) and then it will call add letter, this mean that setter scope will never fire.
    base.OnPropertyChanged("Test"); // my solution is here :) but I hope it has better ways.
}

Is it has another solution for this problem?

  • 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-12T16:24:10+00:00Added an answer on May 12, 2026 at 4:24 pm

    There are 2 ways your Table data could change: Either an element could be added/removed from the collection, or some properties from within an element could change.

    The first scenario is easy to handle: make your collection an ObservableCollection<T>. Invoking .Add(T item) or .Remove(item) on your table will fire a change notification through to the View for you (and the table will update accordingly)

    The second scenario is where you need your T object to implement INotifyPropertyChanged…

    Ultimately your code should look something like this:

        public class MyViewModel
        {
           public ObservableCollection<MyObject> MyData { get; set; }
        }
    
        public class MyObject : INotifyPropertyChanged
        {
           public MyObject()
           {
           }
    
           private string _status;
           public string Status
           {
             get { return _status; }
             set
             {
               if (_status != value)
               {
                 _status = value;
                 RaisePropertyChanged("Status"); // Pass the name of the changed Property here
               }
             }
           }
    
           public event PropertyChangedEventHandler PropertyChanged;
    
           private void RaisePropertyChanged(string propertyName)
           {
              PropertyChangedEventHandler handler = this.PropertyChanged;
              if (handler != null)
              {
                  var e = new PropertyChangedEventArgs(propertyName);
                  handler(this, e);
              }
           }
        }
    

    Now set the datacontext of your View to be an instance of your ViewModel, and bind to the collection, like:

    <tk:DataGrid 
        ItemsSource="{Binding Path=MyData}"
        ... />
    

    Hope this helps 🙂
    Ian

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

Sidebar

Ask A Question

Stats

  • Questions 228k
  • Answers 228k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could add a numeric field to the table, and… May 13, 2026 at 1:36 am
  • Editorial Team
    Editorial Team added an answer Java automatically interns String literals. This means that in many… May 13, 2026 at 1:36 am
  • Editorial Team
    Editorial Team added an answer Did you know you can do this: var connstr =… May 13, 2026 at 1:36 am

Related Questions

I have a WPF project based upon Prism Feb 2009 release set up as:
I'm planning a WPF application which will be able to create dynamic data entry
I am working with a team on LoB application. We would like to have
In my WPF MVVM application my model is a complex tree of Model objects

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.