在加载其他图像的事件时更改图像源

[英]Change image source when loaded event of other image


I'm working with new MS technology UWP. I have 2 images in DataTemplate, CopyImage and MainImage. It's because of image flickering, when source is changed. So I would like to ask, how can I set the source of CopyImage, when event Loaded of MainImage is fired? In WPF I can use DataTriggers, but they are not in UWP. I want to do that in XAML, no in code-behind.

我正在使用新的MS技术UWP。我在DataTemplate,CopyImage和MainImage中有2个图像。这是因为图像闪烁,当源被改变。所以我想问一下,当触发MainImage的事件被触发时,如何设置CopyImage的源代码?在WPF中,我可以使用DataTriggers,但它们不在UWP中。我想在XAML中做到这一点,在代码隐藏中没有。

Many thanks guys

非常感谢你们

EDIT

编辑

<Image Grid.Column="0" x:Name="MainImage" Source="{x:Bind ImageStatusUri, Mode=OneWay}" Margin="0,8,12,8">
 <Image.Triggers>
   <EventTrigger RoutedEvent="Image.Loaded">                   
   </EventTrigger>
 </Image.Triggers>

1 个解决方案

#1


0  

I hope you are using Template10

我希望你使用的是Template10

<Page  xmlns:interact="using:Microsoft.Xaml.Interactivity" 
    xmlns:interactcore="using:Microsoft.Xaml.Interactions.Core">
...
    <Image Grid.Column="0" x:Name="MainImage" Source="{x:Bind ImageStatusUri, Mode=OneWay}" Margin="0,8,12,8" >

                    <interact:Interaction.Behaviors>
                    <interactcore:EventTriggerBehavior EventName="Loaded">
                        <interactcore:ChangePropertyAction PropertyName="Source" Value="" TargetObject="{Binding ElementName=CopyImage}"/>
                    </interactcore:EventTriggerBehavior>
                </interact:Interaction.Behaviors>
            </Image>
</Page>

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/05/24/38abc5bd2bf75e7d616ff4ad3ffa50e0.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com