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 開始畫面和Windows Phone中樞 UI 上看到。

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 的一節。

適用於