CompositionAnimation.SetReferenceParameter(String, CompositionObject) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定一個 Composition 物件的參考,用於 ExpressionAnimation 或 expression 關鍵影格。
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
範例
以下範例說明如何使用 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 上任何可動畫的屬性。 計算運算式值時,會使用合成器中 CompositionObject 目前的屬性值。 更多資訊請參閱 ExpressionAnimation 的備註區。