WPF - 动画用户控制 [英] WPF - Animated User Control

查看:155
本文介绍了WPF - 动画用户控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候

我目前正在申请在WPF,因为我是相当新的WPF我遇到了一些困难。我用Google搜索我的问题,但没有很大的成功。这是目前的情况来看,低于主窗口的XAML:

I'm currently making an application in WPF as I'm fairly new to WPF I'm running into some difficulties. I have Googled my question but with no great success. This is the current situation, XAML of main window below:

<Grid Height="279" HorizontalAlignment="Left" Margin="166,0,0,0" Name="gridScoreboard" VerticalAlignment="Top" Width="808">
    <!--Scoreboard Image-->
    <Image Source="pack://application:,,,/Images/Style/Scoreboard.png" Width="517" Height="91" HorizontalAlignment="Left" Margin="138,1,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" />

    <Canvas Name="canvasRacePlayer1" Width="14" Height="14" Canvas.Left="33" Canvas.Top="66" Background="Transparent" MouseLeftButtonDown="canvasRacePlayer1_MouseLeftButtonDown" Margin="171,70,623,195" />
    <local:ucRaces HorizontalAlignment="Center" Margin="93,62,632,187" Width="78" Visibility="Hidden" x:Name="ucRacesP1" Height="33" />
</Grid>

用户控制是从一开始(ucRaces)隐藏,一旦小布(canvasRacePLayer1)点击用户控件将被显示。不过,我想这个用户控件'滑'从右从某一点到左。至于它是否会成为小步骤可见。我发现信息动画的矩形和按钮,但没有成功真正为用户控件。

The user control is hidden from the start (ucRaces), once the little canvas (canvasRacePLayer1) is clicked the user control will be shown. However I would like this user control to 'slide' from right to left from a certain point. As if it would become visible in small steps. I have found information for animations for rectangles and buttons but no success really for User Controls.

感谢您提前

推荐答案

如果你要为你的WPF项目创建动画,我建议你使用防爆pression混合。您可以通过EB设计程序,并使用Visual Studio实现它的功能。这将是很难做出的动画,写XAML语法或C#code。

If you are going to create animations for your WPF project, I suggest that you use Expression Blend. You can design your program using EB and implement the functionality of it using Visual Studio. It will be hard to make animations, writing XAML syntax or C# code.

您如何能够使用EB动画您的用户控件?嗯,这其实很简单。您需要首先打开现有的WPF项目。然后,转到文件 - >新建项目 - >用户控件,创建用户控制。然后,如果你想将其添加到您的项目中,切换到WPF项目目前在EB打开,然后单击右箭头(>>)放置在屏幕的左侧工具栏上,然后转到项目 - > [您的用户控制这里。现在你已经把它添加到您的项目。

How would you be able to animate your user controls using EB? Well, it is actually very simple. You need to open your existing WPF project first. Then, go to File -> New Item -> User Control, and create the user control. Then, if you want to add it to your project, switch back to the WPF project currently open in EB and click the right arrows (>>) on the toolbar placed on the left-hand side of the screen and go to Project -> [Your User Control Here]. Now you have added it to your project.

如果您要进行动画用户控件,你必须一个故事板添加到您的时间表。当你在你的EB WPF项目,对象和时间线,点击加号(+),并添加一个新的故事板。现在,你有你需要使用动画用户控件的时间表。您可以将时间线KeyTime属性和定义用户控件应该,如果你希望用户控制逐渐变得可见,从位置遵循位置B和透明度也的水平路径。

If you want to animate the user control, you have to add a StoryBoard to your timeline. When you are on your WPF project in EB, under Objects and Timeline, click the plus (+) sign and add a new StoryBoard. Now, you have a timeline that you need to use to animate your user control. You can place KeyTime attributes on the timeline and define the path the user control is supposed to follow from location A to location B and also the level of opacity if you want the user control to gradually become visible.

您可以添加更多的用户控制和执行其第二用户逻辑。防爆pression混合将使您的生活更轻松。

You can add one more user control and implement its logic for the second user. Expression Blend will make your life easier.

这篇关于WPF - 动画用户控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆