绑定和转换器错误有多糟糕.我应该以某种方式处理它们吗? [英] How bad binding and converter errors. Should I handle them somehow?

查看:64
本文介绍了绑定和转换器错误有多糟糕.我应该以某种方式处理它们吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的错误,因为我的控件会自动绑定.据我所知,这没有任何伤害,但我想知道我是否应该为此担心吗?

I have errors like this because my controls self-bind. It doesn't hurt anything as far as I can tell but I wonder if I should worry about this?

System.Windows.Data错误:BindingExpression路径错误: 找不到"CanNavigateLast"属性 'Infrastructure.Controls.Lookup.LookupViewModel' 'Infrastructure.Controls.Lookup.LookupViewModel'(HashCode = 21405046). BindingExpression:路径='CanNavigateLast' DataItem ='Infrastructure.Controls.Lookup.LookupViewModel' (HashCode = 21405046);目标元素是 'Infrastructure.Controls.DitatToolbar'(Name ='');目标属性是 'CanNavigateLast'(类型为'System.Boolean')..

System.Windows.Data Error: BindingExpression path error: 'CanNavigateLast' property not found on 'Infrastructure.Controls.Lookup.LookupViewModel' 'Infrastructure.Controls.Lookup.LookupViewModel' (HashCode=21405046). BindingExpression: Path='CanNavigateLast' DataItem='Infrastructure.Controls.Lookup.LookupViewModel' (HashCode=21405046); target element is 'Infrastructure.Controls.DitatToolbar' (Name=''); target property is 'CanNavigateLast' (type 'System.Boolean')..

或者这个.我知道它为null,并且似乎不会引起任何问题,但是我想知道这是否有问题?

Or this. I know it's null and it doesn't seem to cause any problems but I wonder if that's a problem?

System.Windows.Data错误:"MS.Internal.Data.DynamicValueConverter" 转换器无法转换值空"(类型空"); BindingExpression:路径="FilterFrom" DataItem ='Infrastructure.Controls.Lookup.FilterBoxRow' (HashCode = 57480441);目标元素是 'System.Windows.Controls.NumericUpDown'(名称='');目标属性是 值"(类型"System.Double").System.InvalidOperationException: 无法将null类型转换为System.Double类型.在 MS.Internal.Data.DynamicValueConverter.Convert(对象值,类型 targetType,对象参数,CultureInfo文化) System.Windows.Data.BindingExpression.ConvertToTarget(对象值).

System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value 'null' (type 'null'); BindingExpression: Path='FilterFrom' DataItem='Infrastructure.Controls.Lookup.FilterBoxRow' (HashCode=57480441); target element is 'System.Windows.Controls.NumericUpDown' (Name=''); target property is 'Value' (type 'System.Double').. System.InvalidOperationException: Can't convert type null to type System.Double. at MS.Internal.Data.DynamicValueConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) at System.Windows.Data.BindingExpression.ConvertToTarget(Object value).

推荐答案

理想情况下,您应该不会出现这样的错误

Ideally you should not have any error like this

但是

无需担心此类错误.无效的绑定不会受到任何损害,因为它们不会被视为异常(这会导致巨大的性能损失).不会有任何性能问题或类似的情况

There is nothing to worry about these kind of errors. Invalid bindings don't hurt in any way because they are not treated as exceptions(which cause huge performance hit). There won't be any performance issue or something similar

尽管您可以通过跟踪侦听器看到失败的绑定您会在Visual Studio的输出窗口中看到它们,但是在普通应用中,因为它们没有跟踪侦听器,所以不会对绑定失败产生任何影响.

Although you can see failed bindings through trace listener like you see them in output window of visual studio but in normal app as there will be no trace listeners so there won't be any effect of failed bindings.

这篇关于绑定和转换器错误有多糟糕.我应该以某种方式处理它们吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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