Click here to Skip to main content
15,917,997 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I am doing a project where I need to load a JSON file and it will read the JSON file and in it, there is a String List.

While looping through the List, I need to call their specific pages and wait for it to complete before going to the next page on the List. But every time I do so, the camera page will override the signature page.

If my JSON List is "Signature", "QR", "Camera", it will go in sequence. So "Signature" will be called first then "QR" then "Camera". But "QR" will bring up the camera and it overrides the "Signature" page. How do I fix that?

C#
<pre>Private async Task readJson()
        {
            Config config = JsonConvert.DeserializeObject<Config>(json);

            while (config.Steps.Any())
            { 
                var item = config.Steps.First();

                if (item.Equals("Camera"))
                {
                    Console.WriteLine("Camera");
                    BindingContext = new CapturePhotoVM();
                    await (BindingContext as CapturePhotoVM).TakePicture();

                   
                }
                else if (item.Equals("Signature"))
                {
                    Console.WriteLine("Signature");

                    //var navPage = new NavigationPage(this);
                    await Application.Current.MainPage.Navigation.PushModalAsync(new SignaturePage());

                    //await navPage.PushAsync(new SignaturePage());

                }
                else if (item.Equals("QR"))
                {
                    Console.WriteLine("QR");

                    var navPage = new NavigationPage(this);
                    //Application.Current.MainPage = navPage;

                    await navPage.PushAsync(new ScannerPage());
                }

                config.Steps.Remove(item);

            }


What I have tried:

I tried using PushModalAsync but still can't get it to work.
Posted
Updated 24-Sep-19 3:20am
v2
Comments
F-ES Sitecore 24-Sep-19 4:04am    
What do you mean by "page"? How are you showing these pages?

1 solution

I can see this is Xamarin WPF. I don't believe that the PushModalAsync actually blocks until the modal has completed, instead it simply means that the modal will be pushed into the navigation stack asynchronously. It will still return immediately once the view has been updated.

According to the documentation[^] the PushAsync will complete once the new page has been displayed. If you're intending on doing these in sequence you might need to store the JSON content somewhere and register events for when the modals are opened/closed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900