views:

18

answers:

2

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 behind), which is also when I set the DataContext. Can I disable bindings in XAML and then re-enable them in code behind?

A: 

Take a look at the following two articles on how to temporarily detach binding using Binding.DoNothing.

  1. Prevent a binding from updating too frequently
  2. Is there any way to temporarily detach a binding in WPF?
Zamboni
nice idea, but this doesn't work. Because the binding is broken, the ValueConverter never gets called. My popup is being bound by default to its first bound parent in the Visual Tree (in this case a DevExpress chart) - I need to specify "Binding=Nothing" in Xaml.
taglius
A: 

found the correct syntax - needed to set the datacontext to nothing in Xaml as follows:

 DataContext="{x:Null}
taglius