zoukankan      html  css  js  c++  java
  • silverlight控件动画状态的过渡

    动画代码:

     xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    <vsm:VisualStateManager.VisualStateGroups>
                <vsm:VisualStateGroup x:Name="FocusStateGroup">
                    <vsm:VisualState x:Name="Focus">
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.95" KeySpline="0,0,0.5,1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.95" KeySpline="0,0,0.5,1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </vsm:VisualState>
                    <vsm:VisualState x:Name="Unfocus">
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.95" KeySpline="0,0,0.5,1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.95" KeySpline="0,0,0.5,1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </vsm:VisualState>
                </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>

    后台代码触发动画,并让其从第一个状态过渡到第二个状态

    private void AddContactButton_MouseEnter(object sender, MouseEventArgs e)
            {
                VisualStateManager.GoToState(this, "Focus", true);
            }
    
            private void AddContactButton_MouseLeave(object sender, MouseEventArgs e)
            {
                VisualStateManager.GoToState(this, "Unfocus", true);
            }
    
            protected void InitEvents()
            {
                base.MouseEnter+=(new MouseEventHandler(this.AddContactButton_MouseEnter));
                base.MouseLeave+=(new MouseEventHandler(this.AddContactButton_MouseLeave));
            }
  • 相关阅读:
    第十四周学习报告
    20135206、20135236第四次试验报告
    20135206、20135236第三次试验报告
    第十三周学习报告
    20135206、20135236第二次实验报告
    第十一周学习报告
    20135206于佳心【家庭作业汇总】
    20135236、20135206第一次试验报告
    luogu题解 CF767C 【Garland】
    第七届Code+程序设计全国挑战赛 normal T1 最小路径串
  • 原文地址:https://www.cnblogs.com/lsqandzy/p/4255117.html
Copyright © 2011-2022 走看看