CompositionAnimation.SetExpressionReferenceParameter 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將實作 IAnimationObject 的物件設定為 ExpressionAnimation中的參考參數。
public:
virtual void SetExpressionReferenceParameter(Platform::String ^ parameterName, IAnimationObject ^ source) = SetExpressionReferenceParameter;
void SetExpressionReferenceParameter(winrt::hstring const& parameterName, IAnimationObject const& source);
public void SetExpressionReferenceParameter(string parameterName, IAnimationObject source);
function setExpressionReferenceParameter(parameterName, source)
Public Sub SetExpressionReferenceParameter (parameterName As String, source As IAnimationObject)
參數
- parameterName
-
String
Platform::String
winrt::hstring
要設定的參數的名稱。
- source
- IAnimationObject
來源物件。
範例
// CustomObject that implements IAnimationObject.
class CustomObject : IAnimationObject
{
public CustomObject(Compositor compositor)
{
_targetVisual = compositor.CreateSpriteVisual();
}
// Implement PopulatePropertyInfo method that
// redirects the property named "CustomOffset"
// to the Offset property of the underlying visual.
void IAnimationObject.PopulatePropertyInfo(
string propertyName,
AnimationPropertyInfo propertyInfo)
{
if (propertyName.Equals(“CustomOffset”)
{
_targetVisual.PopulatePropertyInfo(
“Offset”,
propertyInfo);
}
}
private SpriteVisual _targetVisual = null;
}
// Sample usage of CustomObject in an ExpressionAnimation.
void SetupExpression(
Compositor compositor,
IAnimationObject customObject,
SpriteVisual target)
{
var expAnim = compositor.CreateExpressionAnimation(
“customObject.CustomOffset + vector3(100.0f, 0.0f, 0.0f)”);
expAnim.SetExpressionReferenceParameter(“customObject”, customObject);
targetVisual.StartAnimation(“Offset”, expAnim);
}