Esta documentación está archivada y no tiene mantenimiento.

PresentationTraceSources (Clase)

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

Espacio de nombres: System.Diagnostics
Ensamblado: WindowsBase (en windowsbase.dll)

public static class PresentationTraceSources
public final class PresentationTraceSources
public final class PresentationTraceSources
No se puede utilizar esta clase administrada en XAML.

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 Windows Presentation Foundation Application Performance.

WPF Performance Profiling Tools

WPF provides a suite of performance profiling tools that allow you to analyze the run-time behavior of your application and determine the types of performance optimizations you can apply. The following table lists the five performance profiling tools that are included in the Windows SDK tool, WPFPerf:



Event Trace

Use for analyzing events and creating event log files.


Use for analyzing rendering behavior.

ETW Trace Viewer

Record, display, and browse Event Tracing for Windows (ETW) log files in a WPF user-interface format.

Visual Profiler

Use for profiling the use of WPF services, such as layout and event handling, by elements in the visual tree.

Working Set Viewer

Use for analyzing the working set characteristics of your application.

The Visual Profiler tool suite provides a rich, graphical view of performance data. In this screenshot, the CPU Usage section of the Visual Profiler gives you a precise breakdown of an object's use of WPF services, such as rendering and layout.

Visual Profiler display output

Visual Profiler display output

For more information on WPF performance tools, see Performance Profiling Tools for WPF.

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>


Los miembros estáticos públicos (Shared en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0