C#C
C#6mo ago
24 replies
armoire

✅ WPF How to access class instance that is linked to UI via INotifyPropertyChanged

I'm not using MVVM for my project because it is my first ever project (solo) and I don't wanna get it too complicated.

So I've got a class UIManager that implement INotifyPropertyChanged, it's bound to the MainWindow because the datacontext of the window is defined as an instance of this class, I tested it it works. Then I've got classes specifically for each element of the UI that inherit from UIManager, with editable properties. If I put some code that modifies the UI in their constructor, it works.

The question now is how can I access those classes from another class ? I can't just create a new instance of the class and do stuff, because it's not the same instance as the one used by the UI, so how do I do that ?

If I wasn't precise enough please tell me, and any help is appreciated, thx !
Was this page helpful?