Hello Everyone, I have classes in my application generated by Json :-
public class Answer
{
public string answerId { get; set; }
public string answer { get; set; }
}
public class Question
{
public string questionId { get; set; }
public string questionTitle { get; set; }
public string storyUrl { get; set; }
public string correctAnswerId { get; set; }
public List<Answer> answers { get; set; }
}
public class Main
{
public string response { get; set; }
public string message { get; set; }
public string questionType { get; set; }
public string device_id { get; set; }
public string quiz_type { get; set; }
public int totalQuestion { get; set; }
public List<Question> questions { get; set; }
}
I use webclient for this &
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wcDownloadStringCompleted);
wc.DownloadStringAsync(new Uri("my url", UriKind.RelativeOrAbsolute));
now I have to bind data in my xaml. I bind the first question & its option from this code:- my method wcDownloadStringCompleted() consist:-
Main obj = JsonConvert.DeserializeObject(e.Result);
Question ques = new Question
{
questionTitle = obj.questions.Last().questionTitle,
answers = obj.questions.Last().answers.Select(ans => new Answer { answer = ans.answer, answerId = ans.answerId }).ToList(),
questionId = obj.questions.Last().questionId,
storyUrl = obj.questions.Last().storyUrl,
correctAnswerId = obj.questions.Last().correctAnswerId
};
txt.DataContext = ques.questionTitle; // text block
rb1.Content = ques.answers.ElementAt(0).answer; // radio buttons
rb2.Content = ques.answers.ElementAt(1).answer;
rb3.Content = ques.answers.ElementAt(2).answer;
rb4.Content = ques.answers.ElementAt(3).answer;
now my problem starts;- 1. how do i check if a user select any option and click on "Submit" button to get right answer. 2. a "Next" button to get next question
please help me...