2016-07-08 5 views
1

私は普遍的なアプリケーションを開発しています。私はFlipViewを使うことに決めました。私はコードビハインドからSelectionChangedイベントを簡単にアニメーション化できますが、XAMLだけを使用してこのイベントをアニメーション化する方法があるかどうか不思議です。 (BTW、UseTouchAnimationsForAllNavigation = "True" does not work)。私は(限りSelectionChangedイベントがRoutedEventArgsから継承された引数を取るよう)この使用方法は、EventTriggerは大丈夫だと思うFlipView EventTrigger for SelectionChangedイベント

<FlipView x:Name="MultipleItems"> 
       <FlipView.Triggers> 
       <EventTrigger RoutedEvent="Selector.SelectionChanged"> 
        <BeginStoryboard> 
         <Storyboard x:Name="ColorStoryboard"> 
          //do stuff 
         </Storyboard> 
        </BeginStoryboard> 
       </EventTrigger> 
       <FlipView.Triggers> 
    </FlipView> 

、それはまだ私のランタイムエラーを与える: だから、ここで私がやっているの簡単な例ですFlipViewを含むページへのナビゲーション。

エラーは次である:

WinRT information: Failed to assign to property 'Windows.UI.Xaml.EventTrigger.RoutedEvent'. [Line: 69 Position: 35] 

    Additional information: The text associated with this error code could not be found. 

私は正しくそのするRoutedEventプロパティを割り当てる方法がありますと信じて、しかし、私はまだそれを見つけるdidntの。また、私はそのような単純なことのために行動を使用するつもりはありません。

誰でも手助けできますか?

答えて

2

プロジェクトにMicrosoft.Xaml.Behaviors.Uwp.Managedをインストールする必要があります。その後、EventTriggerはUWPプロジェクトでサポートされます。

は、その後、あなたのXAMLで、このように、このパッケージを使用します。

xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" 
xmlns:Core="using:Microsoft.Xaml.Interactions.Core" 
xmlns:Media="using:Microsoft.Xaml.Interactions.Media" 

は今、あなたは、たとえば次のようにFlipViewの背景色を変更することができます。

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <Grid.Resources> 
     <Storyboard x:Key="std" x:Name="std" > 
      <ColorAnimation From="Red" To="Transparent" Duration="0:0:3" 
          Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" 
          Storyboard.TargetName="flipView"/> 
     </Storyboard> 
    </Grid.Resources> 
    <FlipView x:Name="flipView" ItemsSource="{x:Bind flipviewCollection}"> 
     <Interactivity:Interaction.Behaviors> 
      <Core:EventTriggerBehavior EventName="SelectionChanged"> 
       <Media:ControlStoryboardAction Storyboard="{StaticResource std}" /> 
      </Core:EventTriggerBehavior> 
     </Interactivity:Interaction.Behaviors> 
     <FlipView.ItemTemplate> 
      <DataTemplate> 
       <Image Source="{Binding ImageSource}" Stretch="None"/> 
      </DataTemplate> 
     </FlipView.ItemTemplate> 
    </FlipView> 
</Grid> 

あなたが見ることができるように、私はEventTriggerBehaviorを使用しましたイベントの名前はSelectionChangedです。

関連する問題