hi,
from main page navigating to details page on click event
on details page remote images are being loaded in list view
I'm loading list view on list.loaded event to start image downloading on details page
but when I click on button. main page hold for 5 seconds. according to my logic it should not wait or hold for x nomber of seconds, yes it downloads images first on main page then goes to details page.
according to my code, main page should navigate to details page and when list view is loaded then details page should come up with remote images.
why i am facing this behaviour, any help is much appreciated.
regards
What I have tried:
click event from main page
private async void OnInfinixClicked(object sender,EventArgs e)
{
Brands MyBrands = new Brands { name = "infinix" };
Navigation.PushModalAsync(new details(MyBrands));
}
details page code behind
namespace MobilePrice;
public partial class details : ContentPage
{
public ObservableCollection<test> Names { get; set; } = new ObservableCollection<test>();
public details(Brands b)
{
InitializeComponent();
BindingContext = this;
mylistview.Loaded += (s, e) =>
{
mylabel.Text = "my list view loaded";
var filepath = System.IO.Path.Combine(FileSystem.Current.AppDataDirectory, "filenames.txt");
var retrievefiles = new WebClient();
retrievefiles.DownloadFile("https://maliksuhail.github.io/mobileprices/" + b.name.ToString() + "/filenames.txt", filepath);
Debug.WriteLine($"File Path: {filepath}");
StreamReader Textfile = new StreamReader(@filepath);
string line;
while ((line = Textfile.ReadLine()) != null)
{
Debug.WriteLine(line);
Names.Add(new test { ImageUrl = "https://maliksuhail.github.io/mobileprices/" + b.name.ToString() + "/" + line });
}
};
}
}
details page xaml
<Label x:Name="mylabel"></Label>
<ListView x:Name="mylistview" ItemsSource="{Binding Names}" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell >
<Image Source="{Binding ImageUrl}"
SemanticProperties.Description="{Binding ImageUrl}"
Aspect="AspectFit"
VerticalOptions="Start" />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>