在早期故事板之后运行故事板已完成

时间:2014-09-18 09:00:18

标签: c# windows-phone-8 grid storyboard

我正在使用后面的代码在网格上运行故事板,一旦这个故事板完成,我希望在同一网格上运行第二个故事板。我正在考虑使用storyboard.complete,但由于它在同一个对象上,因此无法在那里运行故事板。有没有办法首先在网格上运行一个故事板,一旦完成在同一个对象上运行不同的故事板?

到目前为止我得到的代码:

public void VisibleBars()
    {
        Grid TopBar = (Grid)Gr.FindName("TopBar_Grid");
        Grid ViewPortBar = (Grid)Gr.FindName("ViewPort_Grid");


        //Initialsing animation
        Storyboard StoryTopBar = new Storyboard();
        DoubleAnimation TBHeight = new DoubleAnimation();
        TopBar.RenderTransform = new CompositeTransform();

        if(IsTopBottomVisible)
        {
            TBHeight.From = 0;
            TBHeight.To = -ViewPortBar.Margin.Top;
                }
        else
        {
            TBHeight.To = 0;
            TBHeight.From = -ViewPortBar.Margin.Top;
        }

        TBHeight.Duration = TimeSpan.FromSeconds(2);


        Storyboard.SetTargetProperty(TBHeight, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)"));
        Storyboard.SetTarget(TBHeight, TopBar);
        StoryTopBar.Children.Add(TBHeight);
        StoryTopBar.Begin();

        StoryTopBar.Completed += (e,s) => StoryTopBar_Completed(StoryTopBar,TBHeight,TopBar,ViewPortBar);

    }

private object StoryTopBar_Completed(Storyboard StoryTopBar1, DoubleAnimation TBHeight1, Grid TopBar1, Grid VPBar1)
    {
        //TODO Færdig det sidste så den rykker det lille sidste stykke ud af skærmen
        if (IsTopBottomVisible)
        {
            TBHeight1.To = -TopBar1.ActualHeight;
            TBHeight1.From = -VPBar1.Margin.Top;
            IsTopBottomVisible = false;
        }
        else
        {
            IsTopBottomVisible = true;
        }

        Storyboard.SetTargetProperty(TBHeight1, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)"));
        Storyboard.SetTarget(TBHeight1, TopBar1);
        StoryTopBar1.Children.Add(TBHeight1);
        StoryTopBar1.Begin();

        return true;
    }

0 个答案:

没有答案