0

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.

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>

JuP
  • 535
  • 1
  • 6
  • 23

1 Answers1

0

I hope you are using 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>
Archana
  • 3,213
  • 1
  • 15
  • 21
  • Thanks man. I've tried it, but CopyImage is larger than MainImage, and size of picture is the same. When I'm changing the image, only MainImage changes, not CopyImage. So I think, Loaded event is fired only once. – JuP May 24 '16 at 06:53
  • You said you want to load copyimage when mainimage loads right? – Archana May 24 '16 at 07:06
  • Yes. After event Loaded of MainImage is fired, I need to set the source of CopyImage – JuP May 24 '16 at 07:30
  • So it has to be fired only once right? I dint understand why you mentioned about size. Can you elaborate it? – Archana May 24 '16 at 07:32
  • Not only once. Because I have listview of contacts. And when some contact changes the status online/offline, the image changes too. – JuP May 24 '16 at 07:34
  • Try ImageOpened instead Loaded. And are you telling first time copeimage loads when mainimage loaded? – Archana May 24 '16 at 07:37
  • Yes. I set always copyimage source, when mainimage is loaded. – JuP May 24 '16 at 08:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/112752/discussion-between-jup-and-lovetocode). – JuP May 24 '16 at 08:13