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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:51:30+00:00 2026-06-11T05:51:30+00:00

I have a DataTable that I’m converting to a model which implements INotifyPropertyChanged. This

  • 0

I have a DataTable that I’m converting to a model which implements INotifyPropertyChanged.

This gets bound to a Listbox with a checkbox in it. When the checkbox is checked the PropertyChanged event fires. I want to handle this because I have a DataGrid that is bound to a DataTable. I want to filter that DataTable based on the checked items.

I would like to subscribe to the PropertyChange event in MainWindow.xaml.cs however I’m not sure how to do that as registering a handler in the constructor of my model would create X amount of handlers when I assume I only need one?

Here is what I have:

var categoryModel = ds.Tables[1].Rows.Cast<DataRow>()
                                .Select(x => x["Category"].ToString())
                                .Distinct()
                                .Select(y => new LanguageCategory { CategoryName = y, IsChecked = true });

public class LanguageCategory : INotifyPropertyChanged
    {
        private string categoryName;
        private bool isChecked;
        public event PropertyChangedEventHandler PropertyChanged;

        public string CategoryName
        {
            get { return categoryName; }
            set
            {
                categoryName = value;
                NotifyPropertyChanged("CategoryName");
            }
        }

        public bool IsChecked
        {
            get { return isChecked; }

            set
            {
                isChecked = value;
                NotifyPropertyChanged("IsChecked");
            }
        }


        private void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }
  • 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-11T05:51:32+00:00Added an answer on June 11, 2026 at 5:51 am

    You want the MainWindow to be notified when one of the LanguageCategorys is checked.
    You have two choices.

    1) When you create your list of LanguageCategorys, subscribe to each of their PropertyChanged events. You must remember to unsubscribe from them when you recreate your list.

    2) Create a callback method in MainWindow and pass in a delegate to it when you create each LanguageCatagory. The LanguageCategory can call this when its IsChecked is changed. This is similar to JesseJame’s answer but doesn’t involve another class.
    The advantage of this over 1 being that no cleanup is required when the list changes.

    Example code for 2)

    var categoryModel = ds.Tables[1].Rows.Cast<DataRow>()
                          .Select(x => x["Category"].ToString())
                          .Distinct()
                          .Select(y => new LanguageCategory(OnChecked) { CategoryName = y, IsChecked = true });
    
    public void OnChecked()
    {
       //reload list or whatever
    }
    
    
    public class LanguageCategory : INotifyPropertyChanged
    {
        private string _categoryName;
        private bool   _isChecked;
        private Action _checkedCallback;
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        public LanguageCategory(Action checkedCallback)
        {
           _checkedCallback = checkedCallback;
        }
    
        public string CategoryName
        {
            get { return _categoryName; }
            set
            {
                _categoryName = value;
                NotifyPropertyChanged("CategoryName");
            }
        }
    
        public bool IsChecked
        {
            get { return _isChecked; }
    
            set
            {
                _isChecked = value;
                NotifyPropertyChanged("IsChecked");
                _checkedCallback();
            }
        }
    
        //snip rest of code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 collection datatable that shows in this below Month: January ID NAME
I have a untyped DataTable that looks like this (srcTbl): date col_1 col_2 ...
This is tricky to explain. We have a DataTable that contains a user configurable
I have a LINQ query in C# which runs on a datatable that is
I have this datatable That I want to have different row color for each
I have a datatable that gets modified by having the html stripped out. During
I have this datatable that loadied from the datatabase, here is : <p:dataTable id=cars
Ok. So I am pretty new a this. I have a datatable that I
I have a PrimeFaces dataTable that gets refreshed on actions of various controls of
I have a datatable that stores location values as such: CTY_CD, STATE_CD, COUNTRY_CD and

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.