假设我有这段代码(在 Winforms 中):
public class SomeClass
{
public string Name { get; set; }
}
public partial class SomeControl : UserControl
{
private SomeClass inClass;
public string MyName { get; set; }
public SomeControl(SomeClass someClass)
{
InitializeComponent();
this.inClass = someClass;
SetupBinding();
}
private void SetupBinding()
{
this.DataBindings.Clear();
this.DataBindings.Add("MyName", this.inClass, "Name");
}
}
如果我在用户控件之外更改 SomeClass.Name 的值,则属性 MyName 永远不会改变。我究竟做错了什么?
谢谢