Share via


CompositionAnimation.SetReferenceParameter(String, CompositionObject) Method

Definition

Sets a reference to a Composition object for use with an ExpressionAnimation or an expression keyframe.

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)

Parameters

key
String

Platform::String

winrt::hstring

The name of the parameter to set. The name can be used to reference the parameter in the ExpressionAnimation.

compositionObject
CompositionObject

The CompositionObject value.

Examples

The sample below outlines how to use an ExpressionAnimation to create a parallax effect between a background and foreground visual. This type of animation can be seen on the Windows Start Screen and Windows Phone Hub UIs.

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); 
} 

Remarks

By setting a reference to a CompositionObject, an ExpressionAnimation can refer to any animatable property on that CompositionObject. The CompositionObject's current property value in the Compositor will be used when calculating the value of the expression. See the remarks section of ExpressionAnimation for additional information.

Applies to