public void LoadOptions(Post p) { foreach (Post.Candidate c in p.cand) { PostButton pb = new PostButton(); pb.Height = height; pb.Width = width; pb.Margin = new Thickness(margin); pb.Content = c.Name; pb.CandidateID = c.CandidateID; pb.Click += SelectCandidate; CandidateWrapPanel.Children.Add(pb); Console.WriteLine("loaded " + c.Name); } }
private void SelectCandidate(object sender, RoutedEventArgs e) { PostButton postbutton = (PostButton)sender; selectedCandidate = postbutton.CandidateID; foreach (PostButton pb in CandidateWrapPanel.Children) { pb.Background = MainWindow.PrimaryBrush; } postbutton.Background = MainWindow.HighlightBrush; //foreach (Post.Candidate.Demographic d in MainWindow.post[PostID].cand[(int)selectedCandidate].demo) //{ // MessageBox.Show(d.Name); //} //MessageBox.Show((postbutton.CandidateID + PostID).ToString()); }