private void DisplayQuestion(ExamQuestionPool questionPool)
        {
            txtBody.Text = questionPool.QuestionPool.Body;

            if (questionPool.QuestionPool.Type == "Text")
            {
                opthions.Children.Clear();
                var query = (from Q in service.context.QuestionPools
                             from T in service.context.TextQuestions
                             where Q.CourseID == (short)cmbStudentCourses.SelectedValue && Q.Type == "Text" && T.QuestionPoolID == Q.ID
                             where T.QuestionPoolID == questionPool.QuestionPoolID
                             select new { Q.ID, Q.Body, Q.Type, T.Header, T.Answer }).ToList();               //service.context.TextQuestions.Where(t => t.QuestionPoolID == questionPool.QuestionPoolID).ToList();

                txtHeader.Text = query.ElementAt(0).Header;
                textBox        = new TextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x05, 0x83, 0x06)), FontSize = 20, Width = 300, VerticalAlignment = VerticalAlignment.Center
                };
                opthions.Children.Add(textBox);
                textBox.TextChanged += TextBox_TextChanged;
                try
                {
                    if (Textanswwer[Currentquestion.ID] != "")
                    {
                        textBox.Text = Textanswwer[Currentquestion.ID];
                    }
                }
                catch (Exception e)
                {
                }
            }
            else if (questionPool.QuestionPool.Type == "True/False")
            {
                opthions.Children.Clear();
                var query = (from Q in service.context.QuestionPools
                             from T in service.context.TrueFalseQuestions
                             where Q.CourseID == (short)cmbStudentCourses.SelectedValue && Q.Type == "True/False" && T.QuestionPoolID == Q.ID
                             where T.QuestionPoolID == questionPool.QuestionPoolID
                             select new { Q.ID, Q.Body, Q.Type, T.Header, T.Answer }).ToList();               //service.context.TextQuestions.Where(t => t.QuestionPoolID == questionPool.QuestionPoolID).ToList();

                txtHeader.Text = query.ElementAt(0).Header;
                True           = new RadioButton()
                {
                    Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x05, 0x83, 0x06)), FontSize = 20, Content = true, VerticalAlignment = VerticalAlignment.Center
                };
                False = new RadioButton()
                {
                    Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x05, 0x83, 0x06)), FontSize = 20, Content = false, VerticalAlignment = VerticalAlignment.Center
                };
                opthions.Children.Add(True);
                opthions.Children.Add(False);
                True.Checked  += True_Checked;
                False.Checked += False_Checked;
                try
                {
                    if (truefalseanswer[Currentquestion.ID] == true)
                    {
                        True.IsChecked = true;
                    }
                    else if (truefalseanswer[Currentquestion.ID] == false)
                    {
                        False.IsChecked = true;
                    }
                }
                catch (Exception e)
                {
                }
            }
            else if (questionPool.QuestionPool.Type == "MCQ")
            {
                opthions.Children.Clear();
                var query = (from Q in service.context.QuestionPools
                             from T in service.context.McqQuestions
                             where Q.CourseID == (short)cmbStudentCourses.SelectedValue && Q.Type == "MCQ" && T.QuestionPoolID == Q.ID
                             where T.QuestionPoolID == questionPool.QuestionPoolID
                             select new { Q.ID, Q.Body, Q.Type, T.Header }).ToList();               //service.context.TextQuestions.Where(t => t.QuestionPoolID == questionPool.QuestionPoolID).ToList();

                txtHeader.Text = query.ElementAt(0).Header;
                var choices = service.context.Choices.Where(c => c.QuestionPoolID == questionPool.QuestionPoolID).ToList();
                foreach (var item in choices)
                {
                    checkBox = new CheckBox()
                    {
                        Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x05, 0x83, 0x06)), FontSize = 20, Content = item.Body, VerticalAlignment = VerticalAlignment.Center
                    };
                    opthions.Children.Add(checkBox);
                    checkBox.Checked   += CheckBox_Checked;
                    checkBox.Unchecked += CheckBox_Unchecked;
                    try
                    {
                        if (mcqanswer.ContainsKey(Currentquestion.ID))
                        {
                            if (mcqanswer[Currentquestion.ID].Contains(checkBox.Content.ToString()))
                            {
                                checkBox.IsChecked = true;
                            }
                            else
                            {
                                checkBox.IsChecked = false;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
        }
 private void DisplayExam(int SID, int ExamID)
 {
     Currentquestion = questions.ElementAt(index);
     DisplayQuestion(Currentquestion);
 }