开发者

starting with an empty DataContext on a popup

开发者 https://www.devze.com 2023-01-18 16:03 出处:网络
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

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.

  1. Prevent a binding from updating too frequently
  2. 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}
0

精彩评论

暂无评论...
验证码 换一张
取 消