Many binding errors in visual studio with WPF application?

巧了我就是萌 提交于 2019-12-10 11:57:09

问题


When I debug my app visual studio gives many binding errors like those in the example here:

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; using default instead. BindingExpression:Path=PlanningCd; DataItem=null; target element is 'TextBlock' (Name='planningSchema'); target property is 'NoTarget' (type 'Object')

System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=PlanningCd; DataItem=null; target element is 'TextBlock' (Name='planningSchema'); 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=Measurements; DataItem=null; target element is 'ItemsControl' (Name='MeasurementAndTimeControl'); target property is 'ItemsSource' (type 'IEnumerable')

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

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

System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=PlanningCd; DataItem=null; target element is 'TextBlock' (Name='planningSchema'); 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=OtherParams; DataItem=null; target element is 'ItemsControl' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')

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

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

System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; 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; using default instead. BindingExpression:Path=Measurements; DataItem=null; target element is 'ItemsControl' (Name='MeasurementAndTimeControl'); target property is 'ItemsSource' (type 'IEnumerable')


回答1:


Looks like many of the errors are an an element named 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.

    PresentationTraceSources.TraceLevel="High 



回答2:


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:

Look in Tools > Options > Debugging > Output Window > WPF Trace Settings. Here you can set the level of debugging trace output (between Off and Verbose) and also set the subject matter of output, eg. Animation, Data Binding, etc.

As @Blam has mentioned, you can also change the level of trace output by using the PresentationTraceSources.TraceLevel attached property on your controls.

Further changes could be because you may have configured your PresentationTraceSources differently in your app.config (but only if you use separate config files).



来源:https://stackoverflow.com/questions/7078099/many-binding-errors-in-visual-studio-with-wpf-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!