private void redditNakedDownArrow_Click(object sender, RoutedEventArgs e) { if (sender is Button) { Button myButton = (Button)sender; object maybeAComment = myButton.DataContext; if (maybeAComment is CustomComment) { CustomComment myComment = (CustomComment)maybeAComment; myComment.ChangeVote(VotableThing.VoteType.Downvote); } } }
// I think I have the behaviour right, maybe there is an issue in CustomComment?? // Behaviour if the up arrow HAS been clicked and this click removes the vote (Sets it to None Vote) private void redditUpArrow_Click(object sender, RoutedEventArgs e) { // Is it a button that is sent to me? if (sender is Button) { Button myButton = (Button)sender; object maybeAComment = myButton.DataContext; if (maybeAComment is CustomComment) { CustomComment myComment = (CustomComment)maybeAComment; myComment.ChangeVote(VotableThing.VoteType.None); } } }
private void updateCommentBw_Completed(object sender, RunWorkerCompletedEventArgs e) { List<object> argumentList = e.Result as List<object>; Feed<Comment> comments = argumentList.ElementAt(0) as Feed<Comment>; commentSource.ListComment.Clear(); for (int i = 0; i < comments.Entries.Count<Comment>(); i++) { Comment comment = comments.Entries.ElementAt(i); CustomComment customComment = new CustomComment(comment.Content, comment.Author, comment.Updated.ToString()); commentSource.ListComment.Add(customComment); } this.commentsListBox.DataContext = commentSource; }