Posts Tagged ‘WPF’

Trace Bindings in WPF

Monday, May 11th, 2009

How to trace bindings in WPF?
First add the namespace to your xaml file like this:

<ResourceDictionary xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”

xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

xmlns:diagnostics=”clr-namespace:System.Diagnostics;assembly=WindowsBase”>

Then add the additional magic to your Binding like this:

<ControlTemplate.Triggers>

<DataTrigger Binding=”{Binding diagnostics:PresentationTraceSources.TraceLevel=High, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:ScrollViewerWithVisibilityDetectionControl}}, Path=ShowGradient}” Value=”false”>

<!– setters here –>

</DataTrigger>

</ControlTemplate.Triggers>

Now you get detailed information in the Output window of Visual Studio. :)