microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.38k stars 683 forks source link

SetImplicitShowAnimation not working in ItemsControl with ItemsStackPanel #6483

Open Arlodotexe opened 2 years ago

Arlodotexe commented 2 years ago

Describe the bug

When an ImplicitShowAnimation is set on an element that's hosted inside of an ItemsControl that uses <ItemsStackPanel> as the ItemsPanelTemplate, the animation appear to not run.

Steps to reproduce the bug

Download and run the complete sample from CompositionAnimationsItemsControl.zip

To summarize:

  1. Set up the ItemsControl

    <ItemsControl>
    <ItemsControl.Items>
        <Rectangle x:Name="Rect" Height="200" Width="200" Fill="Red" Visibility="Collapsed" Opacity="0" />
    </ItemsControl.Items>
    
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <!--  Orientation does not matter  -->
            <ItemsStackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    </ItemsControl>
  2. Set up the ImplicitShowAnimation

Compositor compositor = ElementCompositionPreview.GetElementVisual(Rect).Compositor; var animation = compositor.CreateScalarKeyFrameAnimation(); animation.Duration = System.TimeSpan.FromSeconds(1); animation.InsertKeyFrame(0, 0); animation.InsertKeyFrame(1, 1); animation.Target = "Opacity";

ElementCompositionPreview.SetImplicitShowAnimation(Rect, animation);


3. Trigger the animation
```csharp
Rect.Visibility = Windows.UI.Xaml.Visibility.Visible;

Expected behavior

The rectangle should fade in.

Screenshots

No response

NuGet package version

Microsoft.UI.Xaml 2.7.0

Windows app type

Device form factor

Desktop

Windows version

No response

Additional context

Tested on Windows 11 22000.348

StephenLPeters commented 2 years ago

@gegao18 or @stmoy is this an understood issue? I don't see anything obviously wrong.

dpaulino commented 2 years ago

I've been hitting this bug with my app. Any updates here?

michael-hawker commented 1 year ago

Bumping, based on https://github.com/microsoft/microsoft-ui-xaml/discussions/8638