C#C
C#15mo ago
intee_

✅ Invoking an event on property changed (WPF)

Hey all, Just wondering if someone can help me wrap my head around how this works, I am not sure where I am getting caught up but I am sure I am not understanding something. Just started learning WPF and C#. Sorry for the data dump.


I have a text box, a button and a textblock. I am just trying to make the text from the text box be set in the textblock. I have have my bindings working but I don't understand HOW they are working.

I have a PropertyChangedEventHandler in my main window code behind and I have the public and private properties for the binding as well. In the setter of the binding I am calling PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DisplayText"));

This is where I am getting confused I think. When a property is changed on the UI the properties setter is called by that event handler (Handled by INotifyPropertyChanged) (???) How exactly does this part of it work?

I'm not using any relay commands or anything like that, just straight data binding from the UI to the code behind.

Hope this makes at least a little sense...
Was this page helpful?