I have a class called VoucherEntity, includes a Property named “Customer”, a object of Class CustomerEntity, so I have bellow code,
<TextBox Height="23" IsReadOnly="False" HorizontalAlignment="Stretch" Margin="124,48,174,0" Name="txt_customer" VerticalAlignment="Top" Text="{Binding Path=Customer.Name}" />
in .cs file, I have bellow code
_voucher = new VoucherEntity();
this.DataContext = _voucher;
it means, at first, the Customer property is null, after clicked a button, I will give Customer property of _voucher a CustomerEntity object, then I hope the TextBox can display it immediately, but failed, what should I do?
If you want to except changes in your view you should notify the view about the changes.
So just implement the
INotifyPropertyChangedinterface in theVoucherEntityclass and fire thePropertyChangedevent after you set the Customer prop