I am creating a TextBox and a TextBlock at runtime and bind that to the database fields at runtime. The code is below:
LstConfigFields = dbContext.ConfigFields.Where(c => c.ConfigId == this.Uid).ToList();
foreach (ConfigField rec in LstConfigFields)
{
TextBlock TBlock = new TextBlock();
TBlock.Text = rec.TextBlockText;
TextBox TBox = new TextBox();
TBox.SetBinding(TextBox.TextProperty,new Binding(rec.DatabaseField));
if ((bool)rec.IsVisible)
{
stackPanel1.Children.Add(TBlock);
stackPanel1.Children.Add(TBox);
}
}
But I am getting this message :
Two-way binding requires Path or XPath.
Where am I going wrong?
If DatabaseField is read-only you should use OneWay Binding.