Wpf/Silverlight gridview删除行模糊效果

本文关键字:模糊 删除行 gridview Silverlight Wpf | 更新日期: 2023-09-27 18:17:18

删除第一行并再次添加为最后一行。那么,当你从GridView中删除一行时,如何将效果应用到该行呢?

ObservableCollection<Work> perWorks = new ObservableCollection<Work>();
void Timer2_Click(object sender, EventArgs e)
    {
        #region ListBox Remove And Effect / in Process
        if (works.Count > 1)
        {
            Work workTemp = works[0];
            works.RemoveAt(0); 
            works.Add(workTemp);
            DataContext = this; // BindGrid
        }
    }

Wpf/Silverlight gridview删除行模糊效果

设置效果很难,你需要这样做。我认为在你的情况下,GridView行是自动生成的。因此,当您修改数据源时,行将相应更改。

在数据源中删除项目非常快。不可能在删除行或卸载时设置动画,因为它几乎会立即从列表中消失。我的建议是:

1-按住要删除的行。(在这种情况下更简单,因为没有循环)。

2-在xaml或后台代码中调用故事板,如果你想…

3-等待故事板。完成事件,然后调用works.RemoveAt(…)。

所以你有:

void Timer2_Click(object sender, EventArgs e)
{
    #region ListBox Remove And Effect / in Process
    if (works.Count > 1)
    {
        //Work workTemp = works[0];  //Don't know if really needed
          var fade = new DoubleAnimation()
          {
             From = 1,
             To = 0,
             Duration = TimeSpan.FromSeconds(5),
          };
       var item = //TheListBox.Items[];
       Storyboard.SetTarget(fade, item);
       Storyboard.SetTargetProperty(fade,
                                    new PropertyPath(ListBoxItem.OpacityProperty));
       var sb = new Storyboard();
       sb.Children.Add(fade);
       sb.Completed += sb_Completed;
       sb.Begin(); 
    }
}

    void sb_Completed(object sender, EventArgs e)
    {
         works.RemoveAt(0); 
         //works.Add(workTemp);  //Don't know if really needed
         DataContext = this; // BindGrid --Is that correct to define the context each time you click ? :(
    }

让我知道它是否适合你