Many binding errors in visual studio with WPF appl

2019-06-14 13:31发布

问题:

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).