1

我需要像下面有示例的链接一样连续显示图像,如投影翻转动画。

http://www.silverlightbuzz.com/2009/10/14/using-the-3d-tools-to-animate-in-blend/

如何实现上面的示例第二个动画。我们可以在上面的链接中看到两种类型的动画。如何在 Windows 8 中实现第二个这样的动画?这些dllSystem.Windows.Interactivity and Microsoft.Expression.Interactions在windows 8中没有用。那么如何在windows 8中做这个动画呢?

编辑:

<UserControl.Resources>
        <Storyboard x:Name="Storyboard1" RepeatBehavior="Forever">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:02" Value="90"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle1" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="-90"/>
                <EasingDoubleKeyFrame KeyTime="00:00:02" Value="-90"/>
                <EasingDoubleKeyFrame KeyTime="00:00:02.5000000" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:03.5000000" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle1" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)">
                <EasingDoubleKeyFrame KeyTime="00:00:03.5000000" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="00:00:04" Value="90"/>
            </DoubleAnimationUsingKeyFrames>

            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="-90"/>
                <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0"/>
            </DoubleAnimationUsingKeyFrames>

        </Storyboard>
    </UserControl.Resources>

<Grid x:Name="LayoutRoot" Background="Black">


            <Rectangle x:Name="rectangle1" RadiusX="12" RadiusY="12" Height="300" HorizontalAlignment="Center" VerticalAlignment="Center" Width="300">
                <Rectangle.Projection>
                    <PlaneProjection RotationX="-90"/>
                </Rectangle.Projection>
                <Rectangle.Fill>
                    <ImageBrush ImageSource="/Assets/7.png"/>
                </Rectangle.Fill>
            </Rectangle>
            <Rectangle x:Name="rectangle" RadiusX="12" RadiusY="12" Height="300" HorizontalAlignment="Center" VerticalAlignment="Center" Width="300">
                <Rectangle.Projection>
                    <PlaneProjection RotationX="-90"/>
                </Rectangle.Projection>
                <Rectangle.Fill>
                    <ImageBrush ImageSource="/Assets/8.png"/>
                </Rectangle.Fill>
            </Rectangle>




        <Button x:Name="StartAnimation" 
                Content="Start Animation"

                Grid.Row="1" 
                Width="163"
                Height="61" Margin="0,65,0,24" Click="StartAnimation_Click" />

    </Grid>
4

1 回答 1

1

您应该遵循的链接 ..它将告诉您如何制作动画故事板..当您将故事板保存在混合中时,stoyboard 将自动进入 page.resources 部分,您可以在您想要的任何地方的代码中开始它..恰到好处'' StoryboardName.begin();

我给你这个链接很难一步一步地给你所有信息,因为它需要用户界面使用..希望这对你有帮助..

好的,我已经做了一些可能对你有帮助的事情。就像我已经将你的矩形填充绑定到一个你可以随时通过代码更改的属性。就像你可以使用 dispatchertimer 并且在固定间隔之后你可以改变你的矩形的图像一样这个..

<Rectangle x:Name="rectangle1" RadiusX="12" RadiusY="12" Height="300" HorizontalAlignment="Center" VerticalAlignment="Center" Width="300">
        <Rectangle.Projection>
            <PlaneProjection RotationX="-90"/>
        </Rectangle.Projection>
        <Rectangle.Fill>
            <ImageBrush ImageSource="{Binding hello1}"/>
        </Rectangle.Fill>
    </Rectangle>

在您的页面 .cs 中执行此操作..

public sealed partial class MainPage : Page , INotifyPropertyChanged
{


    public MainPage()
    {
        this.InitializeComponent();
        DispatcherTimerSetup();
     //   hello1 = "/Assets/4.jpeg";
         hello1 = new ImageBrush();
        hello1.ImageSource =
            new BitmapImage(
                new Uri(BaseUri, "Assets/1.jpg")
            );

        this.DataContext = this;

    }

    DispatcherTimer dispatcherTimer;
    DateTimeOffset startTime;
    DateTimeOffset lastTime;
    DateTimeOffset stopTime;
    int timesTicked = 1;
    int timesToTick = 10;

    public void DispatcherTimerSetup()
    {
        dispatcherTimer = new DispatcherTimer();
        dispatcherTimer.Tick += dispatcherTimer_Tick;
        dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
        //IsEnabled defaults to false
  //      TimerLog.Text += "dispatcherTimer.IsEnabled = " + dispatcherTimer.IsEnabled + "\n";
        startTime = DateTimeOffset.Now;
        lastTime = startTime;
    //    TimerLog.Text += "Calling dispatcherTimer.Start()\n";
        dispatcherTimer.Start();
        //IsEnabled should now be true after calling start
      //  TimerLog.Text += "dispatcherTimer.IsEnabled = " + dispatcherTimer.IsEnabled + "\n";
    }

    void dispatcherTimer_Tick(object sender, object e)
    {
        rectangle.Fill = hello1;
    }


    private ImageBrush hello;
    public ImageBrush hello1
    {
        get
        {
            return hello;
        }
        set
        {
            hello = value;
            FirePropertyChanged("hello1");
        }
    }


    /// <summary>
    /// Invoked when this page is about to be displayed in a Frame.
    /// </summary>
    /// <param name="e">Event data that describes how this page was reached.  The Parameter
    /// property is typically used to configure the page.</param>


    private void StartAnimation_Click_1(object sender, RoutedEventArgs e)
    {
        Storyboard1.Begin();
      //  Storyboard1.GetCurrentTime =
      //  Storyboard1.
      //  double sd = Storyboard1.GetCurrentTime;

    }


    public event PropertyChangedEventHandler PropertyChanged;
    protected void FirePropertyChanged(string propertyName)
    {
        if (this.PropertyChanged != null)
        {
            this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

}

您可以根据需要对其进行修改..希望这会对您有所帮助..

于 2013-07-16T07:02:34.790 回答