22

I've been trying to get to the bottom of an issue with binding the SelectedItem of my ComboBox, and since I've had no success thus far, 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 Output 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" />
jpierson
  • 16,435
  • 14
  • 105
  • 149
  • I have the same issue.. This has worked for me in the past. Did you find a solution yet? – Shaun Bowe Jun 03 '10 at 19:43
  • 1
    Try the suggestion by WaltiD. In my case it all started working last time I tested it but I suspect that it has to do with my indirectly applying WaltiD's solution when troubleshooting another problem in Visual Studio that has to do with intellisense. – jpierson Jun 10 '10 at 17:01
  • Excellent, just came back to this post and the solution works great. – Shaun Bowe Jun 22 '10 at 18:33

3 Answers3

32

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.

WaltiD
  • 1,932
  • 2
  • 23
  • 25
  • Strangely I came back to this and it appears to be working now. I believe I had to reset my settings in Visual Studio 2010 due to another issue that I was troubleshooting and it does appear now that the setting you pointed out is now set to Warning although I'm not sure what it was set to before when I was having the problem. I'll leave it up to other peoples votes and accept your answer if it seems like the consensus solution. Thanks – jpierson Jun 10 '10 at 16:59
  • Oh dear ... I was turning mad ... used to work with 2008 and didn't know why it stopped working. Thanks a lot. – Ignacio Soler Garcia Oct 02 '11 at 15:50
2

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

RyanHennig
  • 1,072
  • 9
  • 12
0

Also see this answer here - https://stackoverflow.com/a/50282982/3984575

Summary: make sure you are not overriding the settings with a line like this in your code -

System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical;
dvdhns
  • 3,026
  • 2
  • 15
  • 11