I have a WPF app that uses an Entity Framework Model. One of the Entities is an Employee Type. This entity has a LastName and FirstName property among others. But in my xaml, I want to display a full name in my DataGrid. So I created this Partial Class to return the full name and I display this property in the DataGrid. This works great. The FullName is displayed in the DataGrid as expected.
public partial class Employee
{
public string FullName
{
get { return LastName.Trim() + ", " + FirstName.Trim(); }
}
}
The problem I have is that my edit form has textboxes bound to the LastName and FirstName properties. When I update values such as CompanyName, LastName, FirstName, HireDate, etc... all the columns in the DataGrid that were changed get updated correctly, but the FullName property does NOT get updated.
Why doesn't my FullName partial class get updated while the rest of the DataGrid properties do get updated? How do I correct this?
Here is my editform xaml.
<TextBox Grid.Column="1" Name="txtCompany" Text="{Binding SelectedEmployee.Company, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Grid.Column="1" Name="txtFirstName" Text="{Binding SelectedEmployee.FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Grid.Column="1" Name="txtLastName" Text="{Binding SelectedEmployee.LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Grid.Column="1" Name="txtFullName" Grid.Row="2" Margin="2" Text="{Binding SelectedEmployee.FullName" /> -- Also show as column in DataGrid