Creates a binding programmatically

 We can set Binding values through programmatically.We can set the source (value) to today’s date and then linked the binding to the txtBoundProgrammatically text box.
 
//Creates a binding programmatically
public void CreateBinding_programmatically()
{
//Creates a binding programmatically
Binding NewBinding = new Binding("Now");
NewBinding.Source = System.DateTime.Now;
NewBinding.Mode = BindingMode.OneWay;
txtBoundProgrammatically.SetBinding(TextBox.TextProperty, NewBinding);
}

No comments:

Post a Comment