Skip to content

Ability to re-use an animation on multiple controls #635

Open

Description

@dr1rrb

I'm submitting a...

  • Feature request

Current behavior

Animations are tightly coupled with the control (or RenderTransform) that they are animating They cannot be declared in resources and re-used on multiple controls as they can be on Windows.

Expected behavior

A transform can be declared in resources, re-used as RenderTranform on multiple controls across an application, and then animated.

Environment

Nuget Package: Uno.UI
Package Version(s): irrelevant
Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • Windows
  • Build tasks

Visual Studio: irrelevant
Relevant plugins: none

Activity

  1. added
    kind/bug
    on Mar 6, 2019
  2. added
    platform/android 🤖
    platform/ios 🍎
    platform/wasm 🌐
    on May 22, 2019
  3. added
    project/animations 🎡
    on May 27, 2020
  4. modified the milestone: 3.1 on Aug 29, 2020
  5. added
    difficulty/tbd
    on Feb 15, 2021
  6. added
    difficulty/medium 🤔
    and removed
    difficulty/tbd
    on May 31, 2021
  7. ramezgerges commented on Aug 17, 2023

    @ramezgerges
    Contributor

    This is me reporting my findings with the way animations interact on Windows when they affect shared Transforms and the many cases around the idea of animations and transforms being used for multiple targets. This was initially noticed as one of many CommandBar problems being solved in #13214. From here on out, I will refer to cases of a transform being used multiple times as SharedTransform. Similarly, I will name a single animation that's used for different elements, SharedAnimation.

    Code for all cases can be found at https://gist.github.com/ramezgerges/909df0982622c021caf0d5c62f46e631

    • Case 1 Section 1: 2 Animations , 1 Transform, Animation bound to shared Transform by name
      • In this case, we have 2 animations and a TranslateTransform (SharedTransform) in a Resources section. SharedTransform is then used inside 2 Borders as their RenderTransform.
      • The animations target SharedTransform by name (i.e. Storyboard.TargetName="SharedTransform" Storyboard.TargetProperty="X")
      • Quite surprisingly, even if the animation is never ran, the two borders's transform appears to be one and the same. Setting one Border's RenderTransform.X will set move both Borders simultaneously. If the animation runs, we similarly find both borders moving together.
    • Case 1 Section 2: 2 Animations , 1 Transform, Animation bound to UIElement.RenderTransform
      • This is almost identical to the previous case, except this time, the 2 animations are bound to the Borders (i.e. Storyboard.TargetName="Border1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)").
      • Changing one of the Borders' RenderTransform.X will change it for both borders, like they both share the transform. However, the moment an animation is played for one of them, each border seems to behave independently from that point on, Setting or animating one of the borders' RenderTransform.X after that initial animation doesn't affect the other in any way.
    • Case 2: 1 Animation, 1 Transform, Animation bound to shared Transform by name
      • This is self explanatory at this point. The results are similar to Case 1 Section 1.
    • Case 3: 1 animation with 1 Transform inside a DataTemplate.
      • Here, there's a ListView with a DataTemplate containing a Button with VisualStates that change Button.RenderTransform.X. Both the animation and the transform are declared inside the DataTemplate without any usage of StaticResources.
      • Here, each button behaves independently, which is kind of expected since there isn't really anything "shared".This happens whether I'm using Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" on the Button, or Storyboard.TargetProperty="X" on the transform directly.
    • Case 4: 1 animation inside a DataTemplate with the transform referencing a static resource.
      • Similar to Case 3, but here the TranslateTransform is a static resource instead of being defined directly in the DataTemplate.
      • Findings are similar to Case 1 Section 2.
      • Here I'm using Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)". Trying to reference a shared StaticResource Transform from inside the template causes name resolution problems, so I couldn't test with Storyboard.TargetName="SharedTransform" Storyboard.TargetProperty="X".

    Some general related findings

    • Attempting to set a property while it's being animated will never do anything.
    • Attempting to run the animation while it's already running will also do nothing.

    All in all, it seems that the most interesting observation is that StaticResource transforms are cloned at the point of running an animation, but not before.

    Gist
    GitHub Gist: instantly share code, notes, and snippets.
  8. github-actions commented on Jul 17, 2025

    @github-actions
    Contributor

    This issue has become stale with over 1 year of inactivity and will be closed in 10 days unless a comment is provided or the stale label is removed.

  9. added
    stale
    on Jul 17, 2025
  10. removed
    stale
    on Jul 18, 2025
  11. added a commit that references this issue on Mar 6, 2026
  12. MartinZikmund commented on Apr 7, 2026

    @MartinZikmund
    Member

    Repro generator

    Runtime test(s) added in branch dev/mazi/repro/635:

    • src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimation.cs → When_Shared_RenderTransform_Animated_Both_Targets_Move

    ⚠️ The test(s) pass on current master (Skia Desktop) — the managed rendering path correctly handles shared RenderTransform objects across multiple controls. Animating the shared TranslateTransform moves both borders as expected.

    The original bug likely affects iOS/Android native rendering paths where TranslateTransform maps to native view transforms and may be cloned or associated per-view. The branch is provided as a regression guard for the managed path and as a starting point for testing on native platforms.

  13. self-assigned this
    on Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

difficulty/medium 🤔has-repro-branchkind/bugplatform/android 🤖platform/ios 🍎platform/wasm 🌐project/animations 🎡

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions