Wpf datatrigger not updating
It's called Observable Collection, and you use it much like a regular List - that's all it takes!
This will make the Add and Delete button work, but it won't do anything for the "Change name" button, because the change will happen on the bound data object itself and not the source list - the second step will handle that scenario though.
We then add a trigger, which listens to the Is Mouse Over property - once this property changes to True, we apply two setters: We change the Foreground to red and then we make it underlined.
This is a great example on how easy it is to use triggers to apply design changes, completely without any code-behind code.
How to handle them may vary, depending on what you're doing and what you're looking to accomplish, but WPF comes with two very easy solutions that you can use: The Observable Collection and the INotify Property Changed interface.
The following example will show you why we need these two things: Try running it for yourself and watch how even though you add something to the list or change the name of one of the users, nothing in the UI is updated.
They allow you to do stuff that would normally be done in code-behind completely in markup instead, which is all a part of the ongoing process of separating style and code. It watches a specific property on the owner control and when that property has a value that matches the specified value, properties can change.
In theory this might sound a bit complicated, but it's actually quite simple once we turn theory into an example: In this style, we set the Foreground property to blue, to make it look like a hyperlink.
The Items Source of the list is assigned to a quick list of a couple of users that we create in the window constructor.For example, if I make a change that doesn't make the vm invalid, the color is correctly Green.