1

I keep encountering this problem no matter what :

The List<Object> listArticles is simply keep adding data everytime the page appears ,it keep populating the data over and over again instead of simply display them once

I have tried to declare a tempList everytime the function is called , but no success List<PlanDefinition> tempListArticles = new List<PlanDefinition>(listArticles)

How to encouter this problem?

async protected override void OnAppearing()
        {

            listArticles= articleView.getArticlesFromPlan();    
            PopulateOrderLists(listArticles);

            base.OnAppearing();
        }

        protected override void OnDisappearing()
        {

            base.OnDisappearing();
        }






  private void PopulateOrderLists(List<PlanDefinition> listArticles)
            {
                List<PlanDefinition> tempListArticles = new List<PlanDefinition>(listArticles);
                OrderTemplate prod = new OrderTemplate();



            for (var i = 0; i < tempListArticles.Count; i++)
            {
                  prod = new OrderTemplate();

                prod.BindingContext = tempListArticles[i].Name;
                 OrderInformation.Children.Add(prod);

             }

        }

1 Answer 1

2

Only call your PopulateOrderLists once, assumably when the listArticles has not been populated, but adjust it to your requirements of when you want to replace the current listArticles or add to it...

Example:

async protected override void OnAppearing()
{
    if (listArticles != null && listArticles.Count > 0)
    {
       listArticles= articleView.getArticlesFromPlan();    
       PopulateOrderLists(listArticles);
    }
    base.OnAppearing();
}
Sign up to request clarification or add additional context in comments.

1 Comment

I literally have no idea how come I haven't thought about this Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.