2016-07-11 1 views
3

Je souhaite modifier l'image d'arrière-plan sur chaque élément FlipView. Je suis essayer ce code, mais il a déclenché erreur Only IBehavior types are supported in a BehaviorCollection.Comment définir la propriété Image Source par Xaml Behaviors?

Comment régler la source d'image correctement?

<Grid> 
    <i:Interaction.Behaviors> 
     <core:DataTriggerBehavior 
      Binding="{Binding SelectedIndex, ElementName=TourFlipView}" 
      ComparisonCondition="Equal" 
      Value="1" /> 
     <core:ChangePropertyAction 
      TargetObject="{Binding ElementName=TourFlipViewBackgroundImage}" 
      PropertyName="Source" 
      Value="ms-appx:///Assets/Images/2.png" /> 
    </i:Interaction.Behaviors> 

    <Image 
     x:Name="TourFlipViewBackgroundImage" 
     Source="ms-appx:///Assets/Images/1.png" /> 

    <FlipView 
     x:Name="TourFlipView"> 
     ... 
    <FlipView/> 
</Grid> 

Répondre

4

Vous avez presque corrigé avec une petite erreur. mettre votre ChangePropertyAction à l'intérieur DataTriggerBehavior

<i:Interaction.Behaviors> 
    <core:DataTriggerBehavior 
     Binding="{Binding SelectedIndex, ElementName=TourFlipView}" 
     ComparisonCondition="Equal" 
     Value="1" > 
     <core:ChangePropertyAction 
      TargetObject="{Binding ElementName=TourFlipViewBackgroundImage}" 
      PropertyName="Source" 
      Value="ms-appx:///Assets/Images/2.png" /> 
    </core:DataTriggerBehavior> 
</i:Interaction.Behaviors> 
+0

Oh oui! Je vous remercie! –