PresentationTraceSources 類別

定義

提供特別以 Windows Presentation Foundation (WPF) 應用程式為目標的偵錯追蹤支援。

public ref class PresentationTraceSources abstract sealed
public static class PresentationTraceSources
type PresentationTraceSources = class
Public Class PresentationTraceSources
繼承
PresentationTraceSources

範例

下列範例組態檔可追蹤動畫,並將輸出寫入名為 「debug.txt」 的文字檔。 此組態檔只能與.NET Framework應用程式搭配使用。

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

備註

只有在 WPF 應用程式以完全信任模式執行時,才能使用偵錯追蹤。

若要啟用追蹤,您必須先設定登錄機碼,然後必須設定追蹤來源。

  • 若要建立登錄機碼,請將 「HKeyCurrentUser\Software\Microsoft\Tracing\WPF」 底下的reg_dword值設定 ManagedTracing 為 1。

  • 若要在.NET Framework應用程式中設定追蹤來源,請建立應用程式組態檔。 此檔案具有.config副檔名,例如XamlPad.exe.config。

若要達到最佳應用程式效能,則需要在應用程式設計中考慮,並瞭解WINDOWS PRESENTATION FOUNDATION (WPF) 應用程式開發的最佳做法。 如需詳細資訊,請參閱 優化 WPF 應用程式效能

欄位

TraceLevelProperty

識別 TraceLevel 附加屬性。

屬性

AnimationSource

取得動畫追蹤來源。

DataBindingSource

取得資料繫結追蹤來源。

DependencyPropertySource

取得相依性屬性的追蹤來源。

DocumentsSource

取得文件追蹤來源。

FreezableSource

取得 Freezable 追蹤來源。

HwndHostSource

取得 hwnd 裝載追蹤來源。

MarkupSource

取得標記追蹤來源。

NameScopeSource

取得名稱範圍追蹤來源。

ResourceDictionarySource

取得資源字典追蹤來源。

RoutedEventSource

取得路由事件追蹤來源。

ShellSource

取得殼層追蹤來源。

附加屬性

TraceLevel

方法

GetTraceLevel(Object)

取得所指定項目的 TraceLevel 附加屬性值。

Refresh()

強制重新讀取 app.config 檔案,以重新整理追蹤來源。

SetTraceLevel(Object, PresentationTraceLevel)

TraceLevel 附加屬性的值設定為指定的元素。

適用於

另請參閱