如何使通过WPF动画尺寸(给出选择的假象)图像增长? [英] How can I make an Image grow in size (give the illusion of selection) through a WPF animation?
本文介绍了如何使通过WPF动画尺寸(给出选择的假象)图像增长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是pretty新的WPF,甚至更新到WPF动画。我知道有故事板等,但我正在寻找一个特定的效果,所以我可以从那里工作,并修改它。
I'm pretty new to WPF and even newer to animations in WPF. I know there are storyboards, etc. But I'm looking for a specific effect so I can work from there and tinker with it.
谁能给我关于图像控制的MouseDown一个简单的例子(因为在该控制在WPF没有Click事件)使得通过一记漂亮的期待动画形象大?
Can anyone just give me a simple example about on Image control MouseDown (because there is no Click event in this control in WPF) makes the image bigger through a nifty looking animation?
谢谢兄弟。
推荐答案
下面将图像相对于它的电流的大小,而不是改变绝对值规模。这可能是更灵活的。
The following will scale the image relative to it's current size, rather than changing the absolute values. This might be more flexible.
<Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Image x:Name="MyImage" Source="c:\myImage.jpg" Width="250" Height="250">
<Image.RenderTransform>
<ScaleTransform x:Name="ImageScale" ScaleX="1" ScaleY="1" RenderTransformOrigin="0.5, 0.5"/>
</Image.RenderTransform>
<Image.Triggers>
<EventTrigger RoutedEvent="Image.MouseDown">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="ImageScale" Storyboard.TargetProperty="(ScaleTransform.ScaleX)" To="1.5" Duration="0:0:0.25" AutoReverse="True"/>
<DoubleAnimation Storyboard.TargetName="ImageScale" Storyboard.TargetProperty="(ScaleTransform.ScaleY)" To="1.5" Duration="0:0:0.25" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
</Page>
这篇关于如何使通过WPF动画尺寸(给出选择的假象)图像增长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文