<small id='5YPdP'></small><noframes id='5YPdP'>

          <bdo id='5YPdP'></bdo><ul id='5YPdP'></ul>
        <tfoot id='5YPdP'></tfoot>
      1. <i id='5YPdP'><tr id='5YPdP'><dt id='5YPdP'><q id='5YPdP'><span id='5YPdP'><b id='5YPdP'><form id='5YPdP'><ins id='5YPdP'></ins><ul id='5YPdP'></ul><sub id='5YPdP'></sub></form><legend id='5YPdP'></legend><bdo id='5YPdP'><pre id='5YPdP'><center id='5YPdP'></center></pre></bdo></b><th id='5YPdP'></th></span></q></dt></tr></i><div id='5YPdP'><tfoot id='5YPdP'></tfoot><dl id='5YPdP'><fieldset id='5YPdP'></fieldset></dl></div>

        <legend id='5YPdP'><style id='5YPdP'><dir id='5YPdP'><q id='5YPdP'></q></dir></style></legend>
      2. 如何使 EntranceThemeTransition 在自定义面板上工作项目来源?

        时间:2023-09-14

          <bdo id='C17EQ'></bdo><ul id='C17EQ'></ul>
              <tbody id='C17EQ'></tbody>

                  <tfoot id='C17EQ'></tfoot><legend id='C17EQ'><style id='C17EQ'><dir id='C17EQ'><q id='C17EQ'></q></dir></style></legend>
                1. <small id='C17EQ'></small><noframes id='C17EQ'>

                  <i id='C17EQ'><tr id='C17EQ'><dt id='C17EQ'><q id='C17EQ'><span id='C17EQ'><b id='C17EQ'><form id='C17EQ'><ins id='C17EQ'></ins><ul id='C17EQ'></ul><sub id='C17EQ'></sub></form><legend id='C17EQ'></legend><bdo id='C17EQ'><pre id='C17EQ'><center id='C17EQ'></center></pre></bdo></b><th id='C17EQ'></th></span></q></dt></tr></i><div id='C17EQ'><tfoot id='C17EQ'></tfoot><dl id='C17EQ'><fieldset id='C17EQ'></fieldset></dl></div>

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

                  问题描述

                  我无法让 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:

                  <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>
                  

                  知道如何制作动画吗?

                  PS:我在 Loaded 事件上放置了一个 Debug.WriteLine,它被调用了两次,我不知道为什么.这可能会导致问题,因为此动画仅触发一次.可能在添加 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.

                  (也在 MSDN)

                  推荐答案

                  真是个bug.绑定一起应用或在动画之后应用.因为 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:

                  <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>
                  

                  感谢 Franklin Chen 对 MSDN 论坛关于在代码后面添加项目.

                  Thanks Franklin Chen for the insight on MSDN forum about adding the items on code behind.

                  这篇关于如何使 EntranceThemeTransition 在自定义面板上工作项目来源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Windows 10 通用应用程序中的 C# Ftp 上传? 下一篇:在 Windows 设备的屏幕上捕获触摸输入

                  相关文章

                  <i id='tm5ql'><tr id='tm5ql'><dt id='tm5ql'><q id='tm5ql'><span id='tm5ql'><b id='tm5ql'><form id='tm5ql'><ins id='tm5ql'></ins><ul id='tm5ql'></ul><sub id='tm5ql'></sub></form><legend id='tm5ql'></legend><bdo id='tm5ql'><pre id='tm5ql'><center id='tm5ql'></center></pre></bdo></b><th id='tm5ql'></th></span></q></dt></tr></i><div id='tm5ql'><tfoot id='tm5ql'></tfoot><dl id='tm5ql'><fieldset id='tm5ql'></fieldset></dl></div>
                  <legend id='tm5ql'><style id='tm5ql'><dir id='tm5ql'><q id='tm5ql'></q></dir></style></legend>

                2. <small id='tm5ql'></small><noframes id='tm5ql'>

                      <tfoot id='tm5ql'></tfoot>

                        <bdo id='tm5ql'></bdo><ul id='tm5ql'></ul>