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
源对象。
Windows 要求
设备系列 |
Windows 10, version 1809 (在 10.0.17763.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v7.0 中引入)
|
示例
// 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);
}