我想绑定文本框和数据行列,但不起作用。我的代码:
// Member is a DataRow
for(int i=0;i<Member.Table.Count;++i)
{
TextBox textbox = TextBox();
textbox.Text = Member.Field<string>(i);
Binding binding = new Binding(Member.Table.Columns[i].ColumnName);
binding.Source = Member;
binding.Path = new PropertyPath(Member.Table.Columns[i].ColumnName);
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
binding.Mode = BindingMode.TwoWay;
textbox.SetBinding(System.Windows.Controls.TextBox.TextProperty, binding);
}
任何想法?认为