共用方式為


CompositionAnimation.SetReferenceParameter(String, CompositionObject) 方法

定義

設定 Composition 對象的參考,以搭配 ExpressionAnimation表達式主要畫面格使用。

public:
 virtual void SetReferenceParameter(Platform::String ^ key, CompositionObject ^ compositionObject) = SetReferenceParameter;
void SetReferenceParameter(winrt::hstring const& key, CompositionObject const& compositionObject);
public void SetReferenceParameter(string key, CompositionObject compositionObject);
function setReferenceParameter(key, compositionObject)
Public Sub SetReferenceParameter (key As String, compositionObject As CompositionObject)

參數

key
String

Platform::String

winrt::hstring

要設定的參數的名稱。 名稱可用來參考 ExpressionAnimation 中的 參數。

compositionObject
CompositionObject

CompositionObject 值。

範例

下列範例概述如何使用 ExpressionAnimation 在背景和前景視覺效果之間建立視差效果。 您可以在 [開始] 選單 Windows 10 看到這種類型的動畫。

void CreateParallaxExpression(Visual foreground, Visual background) 
{ 
    var animation = _compositor.CreateExpressionAnimation(); 

    animation.Expression = "foreground.Offset * (foreground.Size / background.Size)"; 

    animation.SetReferenceParameter("foreground", foreground); 
    animation.SetReferenceParameter("background", background); 

    background.StartAnimation("Offset", animation); 
} 

備註

藉由設定 CompositionObject 的參考, ExpressionAnimation 可以參考該 CompositionObject 上的任何可動畫屬性。 在計算表達式的值時,將會使用 Compositor 中的 CompositionObject 目前屬性值。 如需詳細資訊,請參閱 ExpressionAnimation 的一節。

適用於