简体   繁体   中英

Programatically turn on and off databinding?

I have a text box declared in xaml that uses databinding to a string property. How do I disable and then re-enable binding in code?

Thanks!

您可以使用BindingOperations.ClearBinding删除绑定,并使用BindingOperations.SetBinding将其重新添加。

我不确定它是否可以工作,但是您可以尝试调用FrameworkElement.SetBinding() ,并为第二个参数传递null

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM