如何通过Xaml行为设置图像源属性?

如何通过Xaml行为设置图像源属性?,xaml,uwp,behavior,Xaml,Uwp,Behavior,我想更改每个FlipView项目的背景图像。 我正在尝试此代码,但它引发了错误行为集合中只支持IBehavior类型。 如何正确设置图像源 <Grid> <i:Interaction.Behaviors> <core:DataTriggerBehavior Binding="{Binding SelectedIndex, ElementName=TourFlipView}" Comparison

我想更改每个FlipView项目的背景图像。 我正在尝试此代码,但它引发了错误
行为集合中只支持IBehavior类型。

如何正确设置图像源

<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>

...

您几乎纠正了一个小错误。将您的
ChangePropertyAction
放入
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>

哦,是的!非常感谢。