using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace TestOfBinding { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private Student stu; public MainWindow() { InitializeComponent(); //stu = new Student(); //Binding binding = new Binding(); //binding.Source = stu; //binding.Path = new PropertyPath("Name"); //BindingOperations.SetBinding(this.textBox, TextBox.TextProperty, binding); this.textBox.SetBinding(TextBox.TextProperty, new Binding("Name") {Source = stu = new Student()}); } private void ButtonClick(object sender, RoutedEventArgs e) { stu.Name += "Name"; } } }