Getting many Binding “Information” in WPF output window

后端 未结 2 406
夕颜
夕颜 2020-12-10 20:24

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 fallbac         


        
2条回答
  •  情书的邮戳
    2020-12-10 21:06

    I agree with Hugo that its nice if we can consider all the feedback given by bindings; but personally I don't think Information type trace messages are that harmful. You definitely need to solve the binding problems marked as Error and Warnings.

    I got binding information like this -

    System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=PlacementTarget.DataContext.RemoveCommand; DataItem='ContextMenu' (Name=''); target element is 'MenuItem' (Name=''); target property is 'Command' (type 'ICommand')

    Now, inside context menu its necessary to use PlacementTarget and unless you open the context menu this binding won't work;

    I have tried to find out some credible source which mentions exact impact of these Information messages, but didn't found any. The link provided by Hugo also mentions Error type output -

    Fix BindingExpression path errors

    If, when debugging your WPF application, you see errors in the output window like:

    System.Windows.Data Error: 40 : BindingExpression path error: 'AcquireFocus' property not found on 'object' ''DataSource' (HashCode=61327894)'. BindingExpression:Path=AcquireFocus; DataItem='DataSource' (HashCode=61327894); target element is 'VsButton' (Name=''); target property is 'AcquireFocus' (type 'Boolean')*

    then, as well as a broken data-binding, you may have a performance problem. WPF tries several different ways to resolve path errors, including searching for attached properties and this is quite expensive. Eliminate all such warnings, and you should be good. Visual Studio 2010 has new options for debugging WPF databindings.

    http://blogs.msdn.com/b/visualstudio/archive/2010/03/02/wpf-in-visual-studio-2010-part-2-performance-tuning.aspx

提交回复
热议问题