[英]How to start a storyboard which is attached to a control inside a data template?
I have a storyboard inside a data template. 我在数据模板中有一个情节提要。 I want to start this only for a certain condition.
我只想在特定条件下开始。 In my case whenever the no.
就我而言,每当没有。 of seconds in the clock is 59 the storyboard should start.
时的秒数为59时,情节提要板应该开始播放。
Below you can see the storyboard as well as the control to which the animation is applied : 在下面,您可以看到情节提要和动画所应用的控件:
<!-- Minute Hand -->
<Image
Source="{Binding Time, Converter={StaticResource MinHandBackground}}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Canvas.Left="118"
Canvas.Top="118">
<Image.RenderTransform>
<TransformGroup>
<TranslateTransform
X="-11"
Y="-90" />
<RotateTransform
x:Name="minHandTransform" />
</TransformGroup>
</Image.RenderTransform>
<Image.Triggers>
<EventTrigger
RoutedEvent="Image.Loaded">
<BeginStoryboard>
<Storyboard
x:Name="myStoryboard2">
<DoubleAnimation
x:Name="minuteAnimation"
Storyboard.TargetName="minHandTransform"
Storyboard.TargetProperty="Angle"
Duration="0:0:1"
From="{Binding Time, Converter={StaticResource minuteHandTransform}}"
To="{Binding Time, Converter={StaticResource minuteHandToTransform}}"
RepeatBehavior="1x">
<DoubleAnimation.EasingFunction>
<SineEase
EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
Currently the BeginStoryboard starts it immediately on load. 当前,BeginStoryboard会在加载后立即启动。 I want to start it when the number of seconds is 59 but i cant access the storyboard in the back end as the control is within a data template.
我想在秒数为59时启动它,但由于控件位于数据模板中,因此我无法访问后端的情节提要。
Can anyone please help me out here.....i have been banging my head about this problem for a lot of days now!! 任何人都可以在这里帮助我.....我已经为这个问题动了很多天了!
最简单的方法是将DataTemplate的全部内容移动到单独的UserControl,这样您就可以更轻松地访问所有命名的元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.