简体   繁体   English

如何启动附加到数据模板内部控件的情节提要?

[英]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.

相关问题 如何从代码隐藏中在用户控件的内容控件中的数据模板中启动故事板? - How do I start a Storyboard in a Data Template in a Content Control in a User Control from codebehind? 如何访问控件模板中的元素? - How to Access an element which is inside a Control Template? 将附加属性绑定到控件模板内的附加属性 - Binding attached property to attached property inside a control template 如何绑定到控件模板内部的控件属性? - How to bind to a control's property which is inside control template? 如何访问列表框数据模板中的控件? - How to access a control placed inside data template of listbox? 用户控件内的情节提要无法正常工作 - Storyboard inside a user control is not working 如何在Silverlight的自定义控件中订阅Attached属性的事件? - How to subscribe to event of Attached property inside custom control in Silverlight? 如何绑定到自定义控件样式内的附加属性? - How to bind to an attached property inside the style of a custom control? 如何获取放置在javascript中gridview的Edit item模板内的控件的clientid - How to get the clientid of the control which is placed inside the Edit item template of the gridview in javascript 控制模板故事板,在同一模板内的其他控件中设置值 - Control Template Storyboard, set value in other control within same template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM