void AddOneElementGridAnfrage(User user) { controlGrid_Anfrage.Children.Add(new Label() { Text = user.Benutzername, FontSize = 40, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.StartAndExpand, VerticalTextAlignment = TextAlignment.Start, HorizontalTextAlignment = TextAlignment.Center }, 0, index_Anfrage); Color color_goto = user.Live == true ? Color.Blue : Color.Gray; ButtonUser button = new ButtonUser() { IdUser = user.Id, Text = "Add", FontSize = 15, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.StartAndExpand }; button.Clicked += Add_clicked; button = new ButtonUser(); controlGrid_Anfrage.Children.Add(button, 1, index_Anfrage); controlGrid_Anfrage.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); index_Anfrage++; }
async void Add_clicked(object sender, EventArgs e) { ButtonUser button = sender as ButtonUser; string json = request.CreateJsonObject(RequestTyp.ConfirmDemand, aktUser, button.IdUser); await DisplayAlert("Josn", json, "Ok"); object repo = request.Execute(json); Responce responce = (Responce)repo; string result = request.GetResponceObject(responce).ToString(); if (responce.Executed) { button.IsEnabled = false; AddOneElementGridHome(ListFriendsToConfirm[button.IdUser]); } else { await DisplayAlert("Error", "Keine Verbindung mit dem Server", "Ok"); } }
void test() { List <User> people = new List <User>(); foreach (var key in ListFriends.Keys) { people.Add(ListFriends[key]); } people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); people.Add(new User() { Benutzername = "Daniel" }); var personDataTemplate = new DataTemplate(() => { var grid = new Grid(); var nameLabel = new Label { FontAttributes = FontAttributes.Bold }; nameLabel.FontSize = 25; var button_add = new ButtonUser { Text = "Add" }; nameLabel.SetBinding(Label.TextProperty, "Benutzername"); grid.Children.Add(nameLabel); grid.Children.Add(button_add, 2, 0); return(new ViewCell { View = grid }); }); Scroll_Home_Anfrage.Content = new StackLayout { Margin = new Thickness(20), Children = { new ListView { ItemsSource = people, ItemTemplate = personDataTemplate, Margin = new Thickness(0, 20, 0, 0) } } }; }
void gotolive_clicked(object sender, EventArgs e) { ButtonUser button = sender as ButtonUser; //Request go to live }