Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XAML:从代码隐藏设置情节提要动画的值_C#_Storyboard_Windows Store Apps_Winrt Xaml - Fatal编程技术网

C# XAML:从代码隐藏设置情节提要动画的值

C# XAML:从代码隐藏设置情节提要动画的值,c#,storyboard,windows-store-apps,winrt-xaml,C#,Storyboard,Windows Store Apps,Winrt Xaml,我有一个要求,我需要一个按钮在几秒钟内从屏幕的一端水平移动到另一端。我试过这个,在一定程度上奏效了 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="button"> <EasingDoubleKeyFrame KeyTim

我有一个要求,我需要一个按钮在几秒钟内从屏幕的一端水平移动到另一端。我试过这个,在一定程度上奏效了

<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="button">
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
            <!--<EasingDoubleKeyFrame KeyTime="0:0:6.9" Value="{Binding MainPage.width}">-->
                <EasingDoubleKeyFrame KeyTime="0:0:6.9" Value="-1283.725">
                <EasingDoubleKeyFrame.EasingFunction>
                    <CircleEase EasingMode="EaseIn"/>
                </EasingDoubleKeyFrame.EasingFunction>
            </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="button">
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
            <!--<EasingDoubleKeyFrame KeyTime="0:0:6.9" Value="{Binding Path=MainPage.height}">-->
            <EasingDoubleKeyFrame KeyTime="0:0:6.9" Value="-467.732">
                <EasingDoubleKeyFrame.EasingFunction>
                    <CircleEase EasingMode="EaseIn"/>
                </EasingDoubleKeyFrame.EasingFunction>
            </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>

如果有简单的方法,请告诉我

我找不到绑定故事板表达式值的方法

但是,解决方法是每次手动设置。我们可以给它一个name属性,如:

    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).    (CompositeTransform.TranslateX)" Storyboard.TargetName="button">
         <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
         <EasingDoubleKeyFrame x:Name="buttonTranslateX"  KeyTime="0:0:9.9" Value="0" />
     </DoubleAnimationUsingKeyFrames>

这将创建一个很好的小动画,其中一个对象将在大约9秒内在屏幕上水平移动

我找不到绑定故事板表达式值的方法

但是,解决方法是每次手动设置。我们可以给它一个name属性,如:

    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).    (CompositeTransform.TranslateX)" Storyboard.TargetName="button">
         <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
         <EasingDoubleKeyFrame x:Name="buttonTranslateX"  KeyTime="0:0:9.9" Value="0" />
     </DoubleAnimationUsingKeyFrames>
这将创建一个很好的小动画,其中一个对象将在大约9秒内在屏幕上水平移动

Rect bounds = Window.Current.Bounds;
static double height = 0;
static double  width = 0;

public MainPage()
{
    this.InitializeComponent();
    this.Loaded += MainPage_Loaded;
    height = bounds.Height;
    width = -1 * bounds.Width;
    buttonTranslateX.Value = width;
}