I'm building desktop application in .NET 4.0 using WPF with SQL Server Compact Edition. I'm using Entity Framework 6.0 Code First approach as my ORM. My POCO class is quite simple:
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName { get { return FirstName + " " + LastName; } }
}
I'm displaying FullName
property in the UI using following code
<TextBox Text="{Binding FirstName, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Text="{Binding LastName, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="{Binding FullName}" />
When I update one of the properties, FirstName
or LastName
, the FullName
doesn't update.
At first, I thought it is because my POCO class doesn't implement INotifyPropertyChanged (I'm to lazy to write OnPropertyChanged method inside all my properties setter :)).
But in the other hand, when I've tried Multibinding... it worked in some magical way:
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Employee.FirstName"/>
<Binding Path="Employee.LastName"/>
</MultiBinding>
Could anybody please explain to me, what event is trigering the UI update and how can I add my little EventHandler to this event?