我一直在试图解决绑定ComboBox的SelectedItem时遇到的问题,但迄今为止没有成功,因此我开始寻找通过设置PresentationTraceSources.TraceLevel=High来获取更详细调试信息的方法。不幸的是,在这样做后,我在Debug类别下的Output窗口中没有看到任何相关的条目。
我正在使用Visual Studio 2010,并且我的项目是一个WinForms项目,大量使用了Interop来使用ElementHost来托管WPF内容。所有相关项目都目前正在构建.NET 3.5版本。如果有任何想法或建议可以帮助我在输出窗口中查看额外的跟踪信息,将不胜感激。
以下是我使用的代码片段。
<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" />