简体   繁体   English

使用 WPF 应用程序的 Visual Studio 中出现许多绑定错误?

[英]Many binding errors in visual studio with WPF application?

When I debug my app visual studio gives many binding errors like those in the example here:当我调试我的应用程序时,Visual Studio 会出现许多绑定错误,例如此处示例中的错误:

Anybody know why this is happening?有人知道为什么会这样吗? Also colleague of mine doesn't have those binding errors but has the same version as me.我的同事也没有那些绑定错误,但与我的版本相同。

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=PlanningCd; BindingExpression:Path=PlanningCd; DataItem=null;数据项=空; target element is 'TextBlock' (Name='planningSchema');目标元素是'TextBlock'(名称='planningSchema'); target property is 'NoTarget' (type 'Object')目标属性是“NoTarget”(类型“对象”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=PlanningCd; BindingExpression:Path=PlanningCd; DataItem=null;数据项=空; target element is 'TextBlock' (Name='planningSchema');目标元素是'TextBlock'(名称='planningSchema'); target property is 'Text' (type 'String')目标属性是“文本”(类型“字符串”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=Measurements; BindingExpression:路径=测量; DataItem=null;数据项=空; target element is 'ItemsControl' (Name='MeasurementAndTimeControl');目标元素是“ItemsControl”(名称=“MeasurementAndTimeControl”); target property is 'ItemsSource' (type 'IEnumerable')目标属性是“ItemsSource”(类型“IEnumerable”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=Foreground;绑定表达式:路径=前景; DataItem=null;数据项=空; target element is 'ItemsControl' (Name='MeasurementAndTimeControl');目标元素是“ItemsControl”(名称=“MeasurementAndTimeControl”); target property is 'Foreground' (type 'Brush')目标属性是“前景”(类型“画笔”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=PlanningCd; BindingExpression:Path=PlanningCd; DataItem=null;数据项=空; target element is 'TextBlock' (Name='planningSchema');目标元素是'TextBlock'(名称='planningSchema'); target property is 'NoTarget' (type 'Object')目标属性是“NoTarget”(类型“对象”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=PlanningCd; BindingExpression:Path=PlanningCd; DataItem=null;数据项=空; target element is 'TextBlock' (Name='planningSchema');目标元素是'TextBlock'(名称='planningSchema'); target property is 'Text' (type 'String')目标属性是“文本”(类型“字符串”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=OtherParams;绑定表达式:路径=其他参数; DataItem=null;数据项=空; target element is 'ItemsControl' (Name='');目标元素是'ItemsControl'(名称=''); target property is 'ItemsSource' (type 'IEnumerable')目标属性是“ItemsSource”(类型“IEnumerable”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=Foreground;绑定表达式:路径=前景; DataItem=null;数据项=空; target element is 'ItemsControl' (Name='');目标元素是'ItemsControl'(名称=''); target property is 'Foreground' (type 'Brush')目标属性是“前景”(类型“画笔”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=IsSelected;绑定表达式:路径=IsSelected; DataItem=null;数据项=空; target element is 'ContentPresenter' (Name='');目标元素是'ContentPresenter'(名称=''); target property is 'NoTarget' (type 'Object')目标属性是“NoTarget”(类型“对象”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=Foreground;绑定表达式:路径=前景; DataItem=null;数据项=空; target element is 'Grid' (Name='');目标元素是'网格'(名称=''); target property is 'Foreground' (type 'Brush')目标属性是“前景”(类型“画笔”)

System.Windows.Data Information: 10: Cannot retrieve value using the binding and no valid fallback value exists; System.Windows.Data 信息:10:无法使用绑定检索值并且不存在有效的备用值; using default instead.改用默认值。 BindingExpression:Path=Measurements; BindingExpression:路径=测量; DataItem=null;数据项=空; target element is 'ItemsControl' (Name='MeasurementAndTimeControl');目标元素是“ItemsControl”(名称=“MeasurementAndTimeControl”); target property is 'ItemsSource' (type 'IEnumerable')目标属性是“ItemsSource”(类型“IEnumerable”)

Looks like many of the errors are an an element named planningSchema.看起来许多错误是一个名为planningSchema 的元素。 I would start with adding the following to that binding.我将从将以下内容添加到该绑定开始。 You can also attach a converter that really does nothing but pass string to string (or date to date).您还可以附加一个转换器,它除了将字符串传递给字符串(或日期到日期)之外什么都不做。 Then you can debug in the converter (or you may find out it does not even get as far as the converted).然后您可以在转换器中进行调试(或者您可能会发现它甚至没有达到转换后的程度)。 It would nice if the debugger would work in the XAML.如果调试器可以在 XAML 中工作,那就太好了。

    PresentationTraceSources.TraceLevel="High 

Also colleague of mine doesn't have those binding errors but has the same version as me.我的同事也没有那些绑定错误,但与我的版本相同。

Your colleague may have a number of things set up differently in his Visual Studio:您的同事在他的 Visual Studio 中可能有许多不同的设置:

Look in Tools > Options > Debugging > Output Window > WPF Trace Settings.查看工具 > 选项 > 调试 > Output Window > WPF 跟踪设置。 Here you can set the level of debugging trace output (between Off and Verbose) and also set the subject matter of output, eg.在这里可以设置调试跟踪 output 的级别(在 Off 和 Verbose 之间),还可以设置 output 的主题,例如。 Animation, Data Binding, etc. Animation,数据绑定等

As @Blam has mentioned, you can also change the level of trace output by using the PresentationTraceSources.TraceLevel attached property on your controls.正如@Blam 所提到的,您还可以通过使用控件上的PresentationTraceSources.TraceLevel附加属性来更改跟踪 output 的级别。

Further changes could be because you may have configured your PresentationTraceSources differently in your app.config (but only if you use separate config files).进一步的更改可能是因为您可能在 app.config 中以不同方式配置了您的 PresentationTraceSources (但前提是您使用单独的配置文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM