-1

我正在尝试使用此代码 Mimicking WP7 Unlock Page Animation获得解锁手机效果

但我真的不知道如何让它工作。我没有经验,Storyboard而且我遇到了错误gridTranslate,因为我没有它的定义。我不知道我是否正确输入了代码。有人可以帮我弄这个吗

我的xml代码是

<Grid Grid.Row="1" x:Name="LockScreenGrid" Visibility="{Binding LockScreenGridVisibility}" ManipulationDelta="lock_ManipulationDelta" ManipulationCompleted="lock_ManipulationCompleted" >
        <Grid.RenderTransform>
            <TranslateTransform x:Name="GridTranslate" />
        </Grid.RenderTransform>
        <Grid.Resources>
            <Storyboard x:Name="LockScreenSlideAnimation">
                <DoubleAnimation Duration="0:0:1" To="-768"  
   Storyboard.TargetProperty="  
   (UIElement.RenderTransform).  
   (CompositeTransform.TranslateY)" 
   Storyboard.TargetName="LockScreenGrid" d:IsOptimized="True"/>
            </Storyboard>

            <Storyboard x:Name="CoastGrid" >
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="LockScreenGrid" Storyboard.TargetProperty="(UIElement.RenderTransform)
.(CompositeTransform.TranslateY)">
                    <EasingDoubleKeyFrame x:Name="coastY"           
        KeyTime="00:00:01" Value="0">
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </Grid.Resources>



    </Grid>

我的 .cs 代码是

 public SlideTest()
    {
        InitializeComponent();
    }
    private void lock_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
    {

        if (this.gridTranslate.TranslateY < 0.0)
        {
            IEasingFunction function;
            this.CoastGrid.Stop();
            this.gridTranslate.TranslateY = e.TotalManipulation.Translation.Y;
            if ((e.IsInertial) && (e.FinalVelocities.LinearVelocity.Y < -1500) ||
            (this.gridTranslate.TranslateY < (base.ActualHeight / -2.0)))
            {

                this.coastY.Value = (-1.0 * this.LockScreenGrid.ActualHeight);
                function = new CircleEase();
                ((CircleEase)function).Ease(1.0);
            }
            else
            {
                this.coastY.Value = 0.0;
                function = new BounceEase();
                ((BounceEase)function).Ease(0);
                ((BounceEase)function).Ease(2);
                ((BounceEase)function).Ease(5.0);
            }
            this.coastY.EasingFunction = function;
            this.CoastGrid.Begin();
        }
    }
    private void lock_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
    {
        e.Handled = true;
        this.gridTranslate.TranslateY = (this.gridTranslate.TranslateY +
        e.DeltaManipulation.Translation.Y);
        if (this.gridTranslate.TranslateY > 0.0)
        {
            this.gridTranslate.TranslateY = 0.0;
        }
    }

这只是我从源代码获得的代码的复制/粘贴。我不知道我是否需要一些参考,或者我是否必须定义gridTranslate

4

1 回答 1

0

您的 XAML 有一个名为 GridTranslate 的元素,而您的代码使用 gridTranslate - 请注意不同的大小写。

于 2013-01-16T06:36:43.057 回答