2012-02-13 15 views
0

私は自分のアプリケーションの1つでアニメーションを作成しようとしています。アニメーションされたUserControl:StoryBoardが起動していませんか?

アニメーションは、リソースに定義されたStoryBoardを持つコントロールで、読み込まれた後にこのStoryBoardを開始します。ここでは(多少取り除か)XAMLのです:私は私の窓の上に、このインスタンスを作成するとき

<UserControl x:Class="LernInsel.Resources.Assets.Water" x:Name="UserControl"> 
    <UserControl.Resources> 
    <Storyboard x:Key="BaseAnimation" x:Name="BaseAnimation" RepeatBehavior="Forever"> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveLeft"> 
      <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="0.45"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2.3" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveRight"> 
      <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="0.45"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2.3" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveLeft_Copy"> 
      <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.39"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveRight_Copy"> 
      <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.39"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveLeft_Copy1"> 
      <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1.5" Value="0.41"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveRight_Copy1"> 
      <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1.5" Value="0.41"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveLeft_Copy2"> 
      <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="0.35"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2.9" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="waveRight_Copy2"> 
      <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="0"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="0.35"/> 
      <EasingDoubleKeyFrame KeyTime="0:0:2.9" Value="0"/> 
     </DoubleAnimationUsingKeyFrames> 
    </Storyboard> 
    </UserControl.Resources> 
<UserControl.Triggers> 
    <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
     <BeginStoryboard Storyboard="{StaticResource BaseAnimation}"/> 
    </EventTrigger> 
</UserControl.Triggers> 
    <Grid> 
    <Rectangle x:Name="Background" Fill="#FF0B5FBC" Height="88" VerticalAlignment="Top"/> 
    <Rectangle x:Name="waveLeft" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="25.5,6,286.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    <Rectangle x:Name="waveRight" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="308.5,6,3.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    <Rectangle x:Name="waveLeft_Copy" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="-3.5,15,315.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    <Rectangle x:Name="waveRight_Copy" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="279.5,15,32.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    <Rectangle x:Name="waveLeft_Copy1" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="45.5,25,266.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    <Rectangle x:Name="waveRight_Copy1" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="0,25,-16.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    <Rectangle x:Name="waveLeft_Copy2" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="-3.5,38,315.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    <Rectangle x:Name="waveRight_Copy2" Fill="{DynamicResource ResourceKey=waveBright}" Height="60" Margin="279.5,38,32.5,0" VerticalAlignment="Top" Opacity="0" RenderTransformOrigin="0.5,0.5"/> 
    </Grid> 
</UserControl> 

が、これはデザイナーでは正常に見える、でもアニメーションが表示されています。実行時に、コントロールは単色ボックス(背景色)として表示されますが、アニメーションは決して開始しません。ブレンドがトリガーを作成した方法が間違っていると分かりますか?

ありがとうございます!

SEBI

+0

キーフレームが表示されません... –

+0

申し訳ありませんが、私は剥奪された意味です...投稿を更新します –

答えて

0

waveBrightが実際にあなたのUserControlの到達可能な範囲で定義されていることを考えると、これを再現することはできません。これは、そのコードの唯一の弱点かもしれません。

+0

ありがとうございました。時にはあなたはちょうど最も罠の馬鹿に遭遇する... –

関連する問題