WPF 绑定(bind) : Object in a object

标签 wpf xaml binding

我在 WPF 中有一个带有 2 个文本框的表单:

<TextBox Name="txtName" Text="{Binding Contact.Name}"/>
<TextBox Name="txtAddressNumber" Text="{Binding Contact.Address.Number}"/>

我有 2 个类(class):

public class ContactEntity
{
  public string Name {get;set;}
  public AddressEntity Address {get;set;}
}

public class AddressEntity
{
  public int Number {get;set}
}

Name 属性绑定(bind)良好。但是 Contact 对象中 Address 对象的 Number 属性不绑定(bind)。我做错了什么?

最佳答案

您可能没有在类中实现 INotifyPropertyChanged,并且可能在绑定(bind)后分配值。如果你尝试 Snoop http://snoopwpf.codeplex.com/您可以找出确切的问题。

关于WPF 绑定(bind) : Object in a object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4899409/

相关文章:

c# - Caliburn Micro Datagrid 绑定(bind)

c# - 处理 MVVM 中的周期性线程

c# - 我不能包含 RelayCommands

c# - 无法从 ListView 中的文本框中获取文本

.net - 如何将此 StackPanel 用作资源

plugins - 如何在 Maven2 构建中执行有序任务

wpf - 根据单元格的内容设置 DataGridRow 的背景

xaml - 如何在Xamarin Forms中用图像填充按钮?

xaml - 如何在 StackLayout 内水平居中 FlexLayout?

c# - 替换: One Property in ViewModel for each TextBox with B: One property returning a (observable) collection