I have been trying to figure out how to create android apps that includes navigation and images, it seems that Xamarin.Forms keeps the images on memory even if you leave the page. Not only that it doesn't recognize that the same image is already loaded in the memory.
So this is too obvious to be a bug so I imagine I'm doing something wrong, can somebody help me to understand how to fix this simple app that describes the problem I have?
namespace RandomApp
{
public class App
{
public static Page GetMainPage()
{
var testPage = new ContentPage(){
Title = "First Page"
};
var testPageButton = new Button(){
Text = "Next Page"
};
testPageButton.Clicked += async (object sender, EventArgs e) => {
await testPage.Navigation.PushAsync(new ContentPage(){
Title = "Second Page",
Content = new StackLayout(){
Children = {new Image(){Source = ImageSource.FromFile("random_image.jpg")}}
}
});
};
testPage.Content = new StackLayout{
Children = {testPageButton}
};
return new NavigationPage(testPage);
}
}
}