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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:45:04+00:00 2026-06-01T10:45:04+00:00

We have a WPF application, let’s say I have a Department object, in it

  • 0

We have a WPF application, let’s say I have a Department object, in it I have an ObservableCollection of Courses, inside each Course I have an ObservableCollection of Teachers, and inside each Teacher I have an ObservableCollection of Student:

Department.cs
—- ObservableCollection Courses

Course.cs
—- ObservableCollection Teachers

Teacher.cs
—- ObservableCollection Students

Student.cs
—- Name, Age, etc

These 4 classes all implemented INotifyPropertyChanged, they are working fine by themselves, what I want to achieve is whenever anything inside the Department object graph is changed, whether it was a student’s age get changed, or a new course added or a teacher removed, anything at all, I want to know about it, ideally via an event like DepartmentChanged (and ideally this only raise once), so I can call some other long running action.

I have a hard time coming up with a clean way to do it. I understand that INotifyPropertyChanged only track property change of a class and ObservationCollection has no idea if one of its items has changed something.

So far I tried nested loop like (pseudo code):

foreach (var course in d.Courses){
    foreach (var teacher in course.Teachers){
        foreach (var student in teacher.Students){
            ((INotifyPropertyChanged)student).PropertyChanged += ...
        }
        teacher.Students.CollectionChanged += ...
    }
}

But as can imagine, this created lots of PropertyChanged events since every property subscribe to that, and the action I wanted to do in Department ended up being executed many many times, which is bad.

I then tried using a timer (each of our class has an IsDirty() to determine if the object has changed) with interval set to 500:

if(department != null && department.IsDirty()){
    //call some long running Action here
}

While this seems to work, somehow I feel this approach is wrong, I’d really like to avoid timer if possible, I would love to hear other suggestions and ideas!

Thanks,

  • 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-01T10:45:06+00:00Added an answer on June 1, 2026 at 10:45 am

    This is just a quick idea, without a timer, can you implement IsDirty event on the Course, & Teacher classes?

    For example, Teacher, managers on PropertyChanged internally (subscribes/unsubscribes properly when Student collection changes).
    When any of its students have a valid change, all it has to do is raise IsDirty event, which all have student obj as a param.

    Course will listen and capture teacher.IsDirty event, and will raise its own course.IsDirty where CourseEventArgs = new CourseEventArgs will have a Course, Teacher with Student that has dirty fields.

    In the Department class you listen to Course IsDirty event and parse the args…

    This idea, seems to do the same thing that you have, but not really, because it handles any PropertyChanged only on the lowest level then takes use of your own events to bubble necessary info to the top. Which separates top classes from Student’s PropertyChanged behavioral implementations as well as extensive chatter..
    Also if on the student level, you make changes (through UI, and post them, click save or whatever) then you can control when IsDirty is being raised, maybe only once.

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

Sidebar

Related Questions

Let's say I have the following code in WPF application: try { // NorthwindDataContext
I have a wpf application that has a button for for each folder under
I have WPF Application where I have One main form and other user controls
I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's
I have a WPF application, where when a user unchecks a checkbox, the application
I have a WPF application (.NET 3.0, VS2008) that displays data in a tab
i have a WPF Application with a LoginWindow to access,so i create a Splash
I have a wpf application (C#) that needs to copy a file to a
We have a WPF Application that runs from both desktop and as a XBAP
I have a WPF application with several windows. I would like to define GLOBAL

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.