Load image dynamically on a grid?

-1

I have this xaml:

<StackLayout Spacing="10" Padding="10" VerticalOptions="Center" Grid.Row="3" Grid.Column="1" >
    <Image x:Name="MyImage" Source="{local:ImageResource Operacional.Images.images1.png}" >
       <Image.GestureRecognizers>
           <TapGestureRecognizer Tapped="OnTrocaImageTapGestureReconizerTapped" NumberOfTapsRequired="1"></TapGestureRecognizer>
       </Image.GestureRecognizers>
   </Image>
</StackLayout>

Clicking on the image (Cover) changes the image. I did this in the behind and it happens that when I click, the first image disappears, but the second does not appear.

void OnTrocaImageTapGestureReconizerTapped(object sender, EventArgs e)
{
     MyImage.Source = "Operacional.Images.fechar1.png";
}
    
asked by anonymous 31.01.2018 / 13:45

1 answer

-1

I solved it like this:

void OnTrocaImageTapGestureReconizerTapped(object sender, EventArgs e) { MyImage.Source = ImageSource.FromResource("Operacional.Images.fechar1.png"); }

    
31.01.2018 / 18:13