Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
swdev:dotnet:wpf:data_binding [2017/06/27 17:17]
smayr [Debugging]
swdev:dotnet:wpf:data_binding [2017/06/27 17:22] (current)
smayr [Add Tracing to Output Window]
Line 1435: Line 1435:
  
 = Debugging = = Debugging =
 +
 +== Add Tracing to Output Window ==
 +
 +1. Add ''diag:PresentationTraceSources.TraceLevel=High'' to your binding.  For example:
 +<code xml>
 +<Window x:Class="WpfApplication1.MainWindow"
 +        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 +        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 +        xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
 +        Title="MainWindow" Height="350" Width="525">
 +    <Grid>
 +        <TextBlock Text="{Binding ThereIsNoDataContext, 
 +            diag:PresentationTraceSources.TraceLevel=High}"/>
 +    </Grid>
 +</Window>
 +</code>
 +
 +2. Add a value converter to the binding, to be able to put a break point in debugger.
 +
 +See more:
 +  * [[https://spin.atomicobject.com/2013/12/11/wpf-data-binding-debug/|How To Debug Data Binding Issues in WPF]]
 +
 +== Enable Debug Output ==
   * Enable WPF debug output. In Visual Studio, Options > Debugging > Output Window > WPF Trace Settings > Data Binding > All.   * Enable WPF debug output. In Visual Studio, Options > Debugging > Output Window > WPF Trace Settings > Data Binding > All.
   * Add a high TraceLevel to your binding: <code csharp>PresentationTraceSources.SetTraceLevel(NewBinding, PresentationTraceLevel.High);</code>   * Add a high TraceLevel to your binding: <code csharp>PresentationTraceSources.SetTraceLevel(NewBinding, PresentationTraceLevel.High);</code>