获得许多绑定"信息"在WPF输出窗口 [英] Getting many Binding "Information" in WPF output window

查看:131
本文介绍了获得许多绑定"信息"在WPF输出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始我的程序,我得到了很多的信息是这样的:

When I start my app I get a lot of information like this:

System.Windows.Data Information: 10 : Cannot retrieve value using the binding and 
no valid fallback value exists; using default instead. 
BindingExpression:Path=Period; DataItem=null; target element is 'TextBlock' (Name=''); 
target property is 'Text' (type 'String')

System.Windows.Data Information: 10 : Cannot retrieve value using the binding and 
no valid fallback value exists; using default instead. 
BindingExpression:Path=DocumentId; DataItem=null; target element is 'TextBlock' (Name=''); 
target property is 'Text' (type 'String')

我应该关心的输出?

Should I care for that output?

推荐答案

是的,你应该。这是最安全的治疗结合反馈(信息,错误等),就像编译器警告和错误。绑定的问题往往会减慢应用程序的执行下来,因为它迫使绑定进行重新评估,并根据我的经验,有时打破他们,你需要重新创建在code的结合。

Yes, you should. It is safest to treat binding feedback (information, errors, etc) just like compiler warning and errors. Binding issues tend to slow the execution of the application down since it forces bindings to be re-evaluated, and in my experience, sometimes breaks them to where you need to recreate the binding in code.

最简单的解决办法,如果可以的话,就是设置 FallbackValue 您的结合可以被视为默认值。例如,如果你已经有一个计数属性的一类,但说时创建视图,你的绑定可能看起来像&LT类可以是在某个时间点空; TextBlock的文本= {结合计数,FallbackValue = 0} /> 这将显示一个0,在文本块,或回退值传递给该转换器,如果有一个使用

The simplest workaround, if you can, is to set the FallbackValue on your binding to a value which can be treated as default. For example, if you have a class which has a "Count" property, but said class can be null at some point in time when your view is created, your binding might look like <TextBlock Text={Binding Count, FallbackValue=0} /> which would display a "0" in the text block, or pass the fallback value to the converter if there is one in use.

这篇关于获得许多绑定&QUOT;信息&QUOT;在WPF输出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆