This documentation is archived and is not being maintained.

PresentationTraceSources Class

Provides debug tracing support that is specifically targeted for Windows Presentation Foundation (WPF) applications.


Namespace:  System.Diagnostics
Assembly:  WindowsBase (in WindowsBase.dll)

public ref class PresentationTraceSources abstract sealed

The PresentationTraceSources type exposes the following members.

Public propertyStatic memberAnimationSourceGets an animation trace source.
Public propertyStatic memberDataBindingSourceGets a data-binding trace source.
Public propertyStatic memberDependencyPropertySourceGets a dependency property trace source.
Public propertyStatic memberDocumentsSourceGets a document trace source.
Public propertyStatic memberFreezableSourceGets a Freezable trace source.
Public propertyStatic memberHwndHostSourceGets an hwnd host trace source.
Public propertyStatic memberMarkupSourceGets a markup trace source.
Public propertyStatic memberNameScopeSourceGets a name scope trace source.
Public propertyStatic memberResourceDictionarySourceGets a resource dictionary trace source.
Public propertyStatic memberRoutedEventSourceGets a routed event trace source.
Public propertyStatic memberShellSourceGets a shell trace source.

Public attached propertyTraceLevelGets or sets a value that specifies the level of detail to trace about a particular object.

Public methodStatic memberGetTraceLevelGets the value of the TraceLevel attached property for a specified element.
Public methodStatic memberRefreshRefreshes trace sources, by forcing the app.config file to be re-read.
Public methodStatic memberSetTraceLevelSets the value of the PresentationTraceSourcesTraceLeve()l attached property to a specified element.

Public fieldStatic memberTraceLevelPropertyIdentifies the TraceLevel attached property.

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".

      <source name="System.Windows.Media.Animation"
switchName="SourceSwitch" >
          <add name="textListener" />
      <add name="SourceSwitch" value="All" />
      <add name="textListener"
           initializeData="Debug.txt" />
    <trace autoflush="true" indentsize="4"></trace>

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.