CompositionObject.StartAnimation Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Перегрузки
| StartAnimation(String, CompositionAnimation) |
Подключает анимацию к указанному свойству объекта и запускает анимацию. |
| StartAnimation(String, CompositionAnimation, AnimationController) |
Подключает анимацию к указанному свойству объекта и запускает анимацию. |
StartAnimation(String, CompositionAnimation)
Соединяет анимацию с указанным свойством объекта и запускает анимацию.
public:
virtual void StartAnimation(Platform::String ^ propertyName, CompositionAnimation ^ animation) = StartAnimation;
void StartAnimation(winrt::hstring const& propertyName, CompositionAnimation const& animation);
public void StartAnimation(string propertyName, CompositionAnimation animation);
function startAnimation(propertyName, animation)
Public Sub StartAnimation (propertyName As String, animation As CompositionAnimation)
Параметры
- propertyName
-
String
Platform::String
winrt::hstring
Свойство, с которым связывается анимация.
- animation
- CompositionAnimation
Анимация, связанная с указанным свойством.
Примеры
void AnimatingVisualOffset(Visual targetVisual)
{
var animation = _compositor.CreateVector3KeyFrameAnimation();
//
// Define specific easing functions.
//
var linear = _compositor.CreateLinearEasingFunction();
var easeIn = _compositor.CreateCubicBezierEasingFunction(
new Vector2(0.5f, 0.0f), new Vector2(1.0f, 1.0f));
var easeOut = _compositor.CreateCubicBezierEasingFunction(
new Vector2(0.0f, 0.0f), new Vector2(0.5f, 1.0f));
//
// Add a set of key frames to describe how the Offset should change over time.
//
animation.InsertKeyFrame(0.00f, new Vector3(100.0f, 100.0f, 0.0f));
animation.InsertKeyFrame(0.25f, new Vector3(300.0f, 100.0f, 0.0f), easeIn);
animation.InsertKeyFrame(0.50f, new Vector3(300.0f, 300.0f, 0.0f), linear);
animation.InsertKeyFrame(0.75f, new Vector3(100.0f, 300.0f, 0.0f), linear);
animation.InsertKeyFrame(1.00f, new Vector3(100.0f, 100.0f, 0.0f), easeOut);
//
// The animation curve defined by the key frames will scale to match the duration.
//
animation.Duration = TimeSpan.FromMilliseconds(4000);
targetVisual.StartAnimation("Offset", animation);
}
Комментарии
Если анимация уже привязана к свойству объекта при вызове StartAnimation, предыдущая примененная анимация будет отключена, а новая анимация будет назначена. Аналогичным образом, установка свойства напрямую приведет к отключению предыдущей анимации, а новое значение свойства вступит в силу.
В следующей таблице показан список анимируемых свойств:
| Объект | Имя свойства | Тип свойства |
|---|---|---|
| Объект класса Visual | AnchorPoint (Точка привязки) | Vector2 |
| --- | CenterPoint (Центральная точка) | Vector3 |
| --- | Offset | Vector3 |
| --- | Непрозрачность | скалярная |
| --- | Ориентация | Vector4 |
| --- | RotationAngle (Угол поворота) | скалярная |
| --- | RotationAxis (Ось поворота) | Vector3 |
| --- | Размер | Vector2 |
| --- | TransformMatrix | Matrix4x4 |
| Объекты класса InsetClip | BottomInset (Углубление вниз) | скалярная |
| --- | LeftInset (Углубление влево) | скалярная |
| --- | RightInset (Углубление вправо) | скалярная |
| --- | TopInset (Углубление вверх) | скалярная |
| CompositionColorBrush | Цвет | Windows.UI.Color |
| CompositionPropertySet | Набор свойств, заданных разработчиком. |
Кроме того, можно анимировать свойства некоторых эффектов в объекте CompositionEffectBrush :
| Имя эффекта | Имя свойства | Тип свойства |
|---|---|---|
| SaturationEffect | Насыщенность | скалярная |
| ColorSourceEffect | Цвет | Vector4 |
| ArithmeticComposite | Offset | скалярная |
| --- | Source1Amount | скалярная |
| --- | Source2Amount | скалярная |
| --- | MultiplyAmount | скалярная |
| Transform2D | TransformMatrix | Matrix3x2 |
| ContrastEffect | Контраст | Float |
| ExposureEffect | Экспозиция | Float |
| HueRotationEffect | Angle | Float |
| SepiaEffect | Интенсивность | Float |
| TemperatureAndTintEffect | температура; | Float |
| --- | Оттенок | Float |
| GammaTransferEffect | RedAmplitude | Float |
| --- | Red Exponent | Float |
| --- | RedOffset | Float |
| --- | GreenAmplitude | Float |
| --- | Green Exponent | Float |
| --- | GreenOffset | Float |
| --- | BlueAmplitude | Float |
| --- | Blue Exponent | Float |
| --- | BlueOffset | Float |
| --- | AlphaAmplitude | Float |
| --- | АльфаЭкспонент | Float |
| --- | AlphaOffset | Float |
Применяется к
StartAnimation(String, CompositionAnimation, AnimationController)
Соединяет анимацию с указанным свойством объекта и запускает анимацию.
public:
virtual void StartAnimation(Platform::String ^ propertyName, CompositionAnimation ^ animation, AnimationController ^ animationController) = StartAnimation;
/// [Windows.Foundation.Metadata.Overload("StartAnimationWithController")]
void StartAnimation(winrt::hstring const& propertyName, CompositionAnimation const& animation, AnimationController const& animationController);
[Windows.Foundation.Metadata.Overload("StartAnimationWithController")]
public void StartAnimation(string propertyName, CompositionAnimation animation, AnimationController animationController);
function startAnimation(propertyName, animation, animationController)
Public Sub StartAnimation (propertyName As String, animation As CompositionAnimation, animationController As AnimationController)
Параметры
- propertyName
-
String
Platform::String
winrt::hstring
Свойство, с которым связывается анимация.
- animation
- CompositionAnimation
Анимация, связанная с указанным свойством.
- animationController
- AnimationController
Контроллер анимации, который необходимо связать с анимацией.
- Атрибуты
Комментарии
Параметр animationController позволяет привязать несколько анимаций к свойству Progress одного контроллера, что требует меньше объектов ExpressionAnimation, чем привязка Progress нескольких свойств аниматора к свойству CompositionObject.