How to set and get updatesourcetrigger of a textbox in codebehind?

前端 未结 3 1843
醉酒成梦
醉酒成梦 2021-01-06 18:05

Just a short question :
In wpf, how do I set and get updatesourcetrigger of a textbox in codebehind ?
Thanks

Update :
I follow

3条回答
  •  旧时难觅i
    2021-01-06 18:26

    I think this the right way to do this:

     Binding binding = new Binding();
    
     binding.Source = new CustomerViewModel();;
     binding.Path = new PropertyPath("Customer.Name");
     binding.Mode = BindingMode.TwoWay;
     binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
     txtCustName.SetBinding(TextBox.TextProperty, binding);
    

提交回复
热议问题