EntranceThemeTransition

EntranceThemeTransition

本文介绍了如何使EntranceThemeTransition工作在自定义面板和放大器;的ItemsSource?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我不能让EntranceThemeTransition到自定义面板ItemsPanelTemplate上工作。参见:

I can't get EntranceThemeTransition to work on a custom panel as ItemsPanelTemplate. See:

背后最简单的代码:

public List<int> MyListExample = new List<int>() {0, 1, 2, 3, 4, 5};



最简单的XAML:

Simplest XAML:

<ListView Width="120" ItemsSource="{x:Bind MyListExample}">
    <ListView.ItemContainerTransitions>
        <TransitionCollection>
            <EntranceThemeTransition FromVerticalOffset="200" IsStaggeringEnabled="True"/>
        </TransitionCollection>
    </ListView.ItemContainerTransitions>

    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <!--EntranceThemeTransition WORKS-->
            <ItemsWrapGrid/>

            <!--EntranceThemeTransition does NOT work-->
            <!--<StackPanel/>-->

            <!--EntranceThemeTransition does NOT work. goal: make this work-->
            <!--<local:FluidPanel/>-->
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>



不知道如何使动画作品?

Any idea how to make the animation works?

PS:我把的Debug.WriteLine上Loaded事件,它被称为两次,我不知道为什么。这可能会引起问题,因为这部动画时才会触发一次。添加的的ItemsSource之前可能被触发。

PS: I put a Debug.WriteLine on the Loaded event, it's being called twice and I have no idea why. This might be causing the problem, because this animation is only triggered once. Possibly is being triggered before the ItemsSource being added.

PS2:它只使用的ItemsSource时发生。如果我直接添加元素上的ListView XAML它显示的动画。

PS2: It only happens when using ItemsSource. If I add the elements directly on the ListView XAML it shows the animation.

(也的)

推荐答案

这实在是一个错误。结合被动画后一起应用或而已。因为EntranceThemeTransition只发生一次,它认为它已经执行,并禁用它。

It is really a bug. The binding gets applied together or just after the animation. Because EntranceThemeTransition just happens once, it thinks that it already executed and disables it.

这是我目前使用的解决方法:

This is the workaround I'm currently using:

C#:

public ObservableCollection<int> items { get; set; } = new ObservableCollection<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

private async void MyListView_Loaded(object sender, RoutedEventArgs e)
{
    foreach (var item in items)
        MyListView.Items.Add(item);

    await Task.Delay(1000); //wait for animation
    MyListView.SetBinding(ItemsControl.ItemsSourceProperty, new Binding() { Source = this, Path = new PropertyPath("items"), Mode = BindingMode.TwoWay });
}





XAML:


XAML:

<ListView x:Name="MyListView" Loaded="MyListView_Loaded">
    <ListView.ItemContainerTransitions>
        <TransitionCollection>
            <EntranceThemeTransition FromHorizontalOffset="0" FromVerticalOffset="2000" IsStaggeringEnabled="True"/>
        </TransitionCollection>
    </ListView.ItemContainerTransitions>

    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel/>
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>



感谢富兰克林陈上的。

这篇关于如何使EntranceThemeTransition工作在自定义面板和放大器;的ItemsSource?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 03:19