I have a popup that is bound at runtime to elements of a chart. The bindings are defined in XAML. When the application starts, I am getting many errors in the Immediate Window because the XAML bindings aren't valid (by design).
I need a way to disable binding on this popup until I am about to display it during a mouseover event (in code 开发者_StackOverflow社区behind), which is also when I set the DataContext. Can I disable bindings in XAML and then re-enable them in code behind?
Take a look at the following two articles on how to temporarily detach binding using Binding.DoNothing.
- Prevent a binding from updating too frequently
- Is there any way to temporarily detach a binding in WPF?
found the correct syntax - needed to set the datacontext to nothing in Xaml as follows:
DataContext="{x:Null}
精彩评论