PresentationTraceSources Class
Provides debug tracing support that is specifically targeted for Windows Presentation Foundation (WPF) applications.
Namespace: System.Diagnostics
Assembly: WindowsBase (in WindowsBase.dll)
The PresentationTraceSources type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | AnimationSource | Gets an animation trace source. |
![]() ![]() | DataBindingSource | Gets a data-binding trace source. |
![]() ![]() | DependencyPropertySource | Gets a dependency property trace source. |
![]() ![]() | DocumentsSource | Gets a document trace source. |
![]() ![]() | FreezableSource | Gets a Freezable trace source. |
![]() ![]() | HwndHostSource | Gets an hwnd host trace source. |
![]() ![]() | MarkupSource | Gets a markup trace source. |
![]() ![]() | NameScopeSource | Gets a name scope trace source. |
![]() ![]() | ResourceDictionarySource | Gets a resource dictionary trace source. |
![]() ![]() | RoutedEventSource | Gets a routed event trace source. |
![]() ![]() | ShellSource | Gets a shell trace source. |
| Name | Description | |
|---|---|---|
![]() | TraceLevel | Gets or sets a value that specifies the level of detail to trace about a particular object. |
| Name | Description | |
|---|---|---|
![]() ![]() | GetTraceLevel | Gets the value of the TraceLevel attached property for a specified element. |
![]() ![]() | Refresh | Refreshes trace sources, by forcing the app.config file to be re-read. |
![]() ![]() | SetTraceLevel | Sets the value of the PresentationTraceSources.TraceLevel attached property to a specified element. |
Debug tracing is only available when a WPF application is running in full trust mode.
In order to enable tracing, you first must set a registry key, then you must configure trace sources.
To create the registry key, set a "ManagedTracing" reg_dword value to 1 under "HKeyCurrentUser\Software\Microsoft\Tracing\WPF".
To configure trace sources, create an application config file. This file has a .config extension, for example, XamlPad.exe.config.
Achieving optimal application performance requires forethought in application design and an understanding of best practices for Windows Presentation Foundation (WPF) application development. For more information, see Optimizing WPF Application Performance.
The following sample configuration file enables tracing of animations, writing the output to a text file called "debug.txt".
<configuration>
<system.diagnostics>
<sources>
<source name="System.Windows.Media.Animation"
switchName="SourceSwitch" >
<listeners>
<add name="textListener" />
</listeners>
</source>
</sources>
<switches>
<add name="SourceSwitch" value="All" />
</switches>
<sharedListeners>
<add name="textListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="Debug.txt" />
</sharedListeners>
<trace autoflush="true" indentsize="4"></trace>
</system.diagnostics>
</configuration>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



