0

私の目標は、たとえばTextBlockの単純なアニメーション(es failIn、fadeOut)を実行することです。どうすればいいですか?説明を検索しましたが、シナリオなどについて話していると、非常に複雑であることがわかりました。もっと簡単にできるのか、誰かが手順の簡単な説明をしてくれるのか、私は知っているでしょう。

前もって感謝します。

4

2 に答える 2

1

このコードは、それを行う方法のアイデアを提供するはずです (遅すぎる場合は、期間を短縮できます)。これは Xaml です。

<Grid Grid.Row="1">
    <Grid.Resources>
        <Storyboard x:Name="FadeOutStoryboard">
            <!-- This animation will animate the value of the Canvas.Left property of the rectangle Scenario1Rectangle to 300. -->
            <DoubleAnimation 
        Storyboard.TargetName="txtToFade" 
        Storyboard.TargetProperty="Opacity" 
        Duration="0:0:1" 
        To="0" 
        />
        </Storyboard>
        <Storyboard x:Name="FadeInStoryboard">
            <!-- This animation will animate the value of the Canvas.Left property of the rectangle Scenario1Rectangle to 300. -->
            <DoubleAnimation 
        Storyboard.TargetName="txtToFade" 
        Storyboard.TargetProperty="Opacity" 
        Duration="0:0:1" 
        To="1" 
        />
        </Storyboard>
    </Grid.Resources>
    <StackPanel>
        <TextBox Name="txtToFade"></TextBox>
    </StackPanel>
</Grid>

そして、この背後にあるコードでは、ストーリーボードを実行する方法を示しています:-

 FadeOutStoryboard->Begin(); 

また

 FadeInStoryboard->Begin(); 

VisualStateManagerを使用して、イベント (マウス オーバーなど) に基づいてアニメーションを制御できます。

于 2012-12-21T09:48:42.693 に答える
0

この場所でアニメーション サンプルを試しましたか?

http://code.msdn.microsoft.com/windowsapps/Animations-f758de70

于 2012-12-18T11:05:08.513 に答える