CompositionTarget.Rendering 事件

定義

呈現複合樹狀中物件之前發生。Occurs just before the objects in the composition tree are rendered.

public:
 static event EventHandler ^ Rendering;
public static event EventHandler Rendering;
member this.Rendering : EventHandler 
Public Shared Custom Event Rendering As EventHandler 

事件類型

EventHandler

範例

Rendering事件會在轉譯過程中 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 引發。The Rendering event is raised during the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) rendering process. 下列範例顯示如何 EventHandler 在上註冊靜態方法的委派 Rendering CompositionTargetThe following example shows how you register an EventHandler delegate to the static Rendering method on CompositionTarget.

// Add an event handler to update canvas background color just before it is rendered.
CompositionTarget.Rendering += UpdateColor;
' Add an event handler to update canvas background color just before it is rendered.
AddHandler CompositionTarget.Rendering, AddressOf UpdateColor

您可以使用您的轉譯事件處理常式來建立自訂繪圖內容。You can use your rendering event handler to create custom drawing content. 這個事件處理常式會針對每個畫面格呼叫一次。This event handler gets called once per frame. 每次將 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 視覺化樹狀結構中保存的轉譯資料封送處理至組合樹狀結構時,就會呼叫您的事件處理常式。Each time that Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) marshals the persisted rendering data in the visual tree across to the composition tree, your event handler is called. 此外,如果視覺效果樹狀結構的變更強制更新組合樹狀結構,則也會呼叫您的事件處理常式。In addition, if changes to the visual tree force updates to the composition tree, your event handler is also called. 請注意,計算版面配置之後,會呼叫您的事件處理常式。Note that your event handler is called after layout has been computed. 不過,您可以在事件處理常式中修改配置,這表示版面配置會在轉譯前再計算一次。However, you can modify layout in your event handler, which means that layout will be computed once more before rendering.

備註

Rendering 動畫之後,事件會路由傳送至指定的事件處理常式,並將版面配置套用至組合樹狀結構。The Rendering event is routed to the specified event handler after animation and layout have been applied to the composition tree.

適用於