Reputation: 2593
I have a form in WPF with 2 textbox :
<TextBox Name="txtName" Text="{Binding Contact.Name}"/>
<TextBox Name="txtAddressNumber" Text="{Binding Contact.Address.Number}"/>
and I have 2 class :
public class ContactEntity
{
public string Name {get;set;}
public AddressEntity Address {get;set;}
}
public class AddressEntity
{
public int Number {get;set}
}
The Name property binds fine. But the Number property of the Address object inside the Contact object does not binds. What I'm doing wrong ?
Upvotes: 3
Views: 2850
Reputation: 35126
You may not be implementing INotifyPropertyChanged in the classes and may be assigning the value after the binding. If you try Snoop http://snoopwpf.codeplex.com/ you can find out the exact problem.
Upvotes: 3
Reputation: 4909
There's a few good resources for debugging bindings here. I've used the converter method detailed very successfully.
Upvotes: 1
Reputation: 20746
Everything looks fine, check that the Address property is not null when binding occurs. Also you can check Visual Studio output window while under debug to see whether there are any binding errors.
Upvotes: 2