Hi,
I have this code, where I loop through an array and make a grid and add it to the StackLayout, and then when you click one it takes you to the next page..
using System;
using Newtonsoft;
using Newtonsoft.Json.Linq;
using Xamarin.Forms;
namespace App
{
public class PendingChats : ContentPage
{
//public StackLayout sl;
//public ScrollView scroll;
public static bool NotAccepted = false;
public static PendingUsers[] pendingUserList = DependencyService.Get<GetPendingChats>().ListChats(DataAccess.Url + ?sso=" + DataAccess.SSOToken + "&action=pendingchats");
public static int UserSelected = 0;
public PendingChats () {
ScrollView scroll = new ScrollView ();
Title = "Pending Chats";
Content = scroll;
scroll.Content = DrawList();
}
public StackLayout DrawList() {
PendingUsers[] pendingUserList = DependencyService.Get<GetPendingChats>().ListChats(DataAccess.Url + ?sso=" + DataAccess.SSOToken + "&action=pendingchats");
StackLayout stack = new StackLayout {
Spacing = 0,
};
stack.Children.Clear ();
for (int i = 0; i < pendingUserList.Length; i++) {
Grid g = new Grid { RowSpacing = 0, Padding = new Thickness(10, 5, 10, 5), ClassId = i.ToString() };
g.ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) });
g.RowDefinitions.Add (new RowDefinition { Height = new GridLength (25, GridUnitType.Absolute) });
g.RowDefinitions.Add (new RowDefinition { Height = new GridLength (25, GridUnitType.Absolute) });
g.RowDefinitions.Add (new RowDefinition { Height = new GridLength (5, GridUnitType.Absolute) });
g.RowDefinitions.Add (new RowDefinition { Height = new GridLength (1, GridUnitType.Absolute) });
g.Children.Add (new BoxView { BackgroundColor = Color.White }, 0, 0);
g.Children.Add (new BoxView { BackgroundColor = Color.White }, 0, 1);
g.Children.Add (new Label { Text = pendingUserList[i].visitor_name, VerticalOptions = LayoutOptions.Center, TextColor = Color.Black }, 0, 0);
g.Children.Add (new Label { Text = pendingUserList[i].timestamp, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, TextColor = Color.Black }, 0, 0);
g.Children.Add (new Label { Text = pendingUserList[i].question, VerticalOptions = LayoutOptions.Center, TextColor = Color.FromHex("98989B") }, 0, 1);
g.Children.Add (new BoxView { BackgroundColor = Color.White }, 0, 2);
g.Children.Add (new BoxView { BackgroundColor = Color.FromHex("CBCBCE") }, 0, 3);
stack.Children.Add (g);
var GridTap = new TapGestureRecognizer();
GridTap.Tapped += (s, e) => {
NotAccepted = true;
UserSelected = Convert.ToInt32(g.ClassId);
Navigation.PushAsync(new Chat(pendingUserList[Convert.ToInt32(g.ClassId)].sessionid));
NotAccepted = false;
};
g.GestureRecognizers.Add(GridTap);
}
return stack;
}
}
}
But I go to the next page, Click a button and it returns back here.. however the list hasn't updated but when i breakpoint through it the array does have the item which has been deleted out of it and when I reboot the app its how it should be