开发者

Winforms DataBinding

There's a text box and some view model with detail

public class Detail { public string Value {get;set;}}

public class SomeVM
{
     public Detail {get;set;}
}

Trying to bind to textbox with this code:

textBox.DataBindings.Add开发者_StackOverflow社区("Text", new SomeVm (), "Detail.Value");

But it says "there's no property to bind". Is there a solution for this problem?


Have you tried:

public string Value 
{
  get
  {
      return _someVm.Value;
  }
  set
  {
      _someVm.Value=value;
  }
} 
private readonly SomeVM _someVM=new SomeVM();
 ...
textBox.DataBindings.Add("Text", _someVm, "Value");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜