Any reason why PresentationTraceSources.TraceLevel=High would not print any info to the output window?

ⅰ亾dé卋堺 提交于 2019-12-18 11:23:17

问题


I've been trying to get to the bottom of an issue with binding the SelectedItem of my ComboBox and since I've had not success thusfar I started looking at ways to get more detailed debugging information by setting PresentationTraceSources.TraceLevel=High for specific bindings. Unfortunately after doing so I don't see any related items in my Ouput window under the Debug category.

I'm using Visual Studio 2010 and my project is a WinForms project with heavy usage of interop using ElementHost to host WPF content. All related projects are currently being built for .NET 3.5. Any thoughts or suggestions that may lead me to the solution of seeing the extra trace information in the output window will be appreciated.

Below is a snippet of the code I'm using.

<ComboBox xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
            SelectedItem="{Binding Path=MyCollection.SelectedItem, Mode=TwoWay, diagnostics:PresentationTraceSources.TraceLevel=High}"
            ItemsSource="{Binding MyCollection, diagnostics:PresentationTraceSources.TraceLevel=High}"
            SelectedValuePath="Value"
            DisplayMemberPath="Value.DisplayName" />

回答1:


It's a setting in the Visual Studio 2010:

Tools -> Options -> Debugging -> Output Window -> WPF Trace Settings -> Data Binding -> set to Warning (or whatever you like).

Standard was Off.

This solution worked for me.




回答2:


Make sure that your DataContext is not null. If it is, no information will be logged to the output window



来源:https://stackoverflow.com/questions/2802662/any-reason-why-presentationtracesources-tracelevel-high-would-not-print-any-info

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