텍스트 내용을 텍스트 블록에 표시하는 중입니다. 데이터가 목록에서 검색되고 있습니다. 버튼을 반복해서 누르면 텍스트 블록의 내용이 목록에서 변경됩니다. 내 코드는 목록의 모든 텍스트를 표시하고 모든 텍스트가 표시되었을 때 사용자에게 알립니다.목록에서 텍스트 블록에 제한된 텍스트를 표시하는 방법
예를 들어 목록에 100 개의 항목이있는 경우 사용자 작업에 의해 하나씩 총 100 개의 질문이 표시됩니다. 내가 원하는 건 내 질문 100 개 중 10 개만 채울 수있는 방법이다. 따라서 10 개의 텍스트가 표시된 후에 완성 된 메시지가 표시됩니다. 나는 또한 각 텍스트가 바뀔 때 목록을 무작위로 추출하고 섞어 놓고 싶다. 그래서 사용자는 페이지를 열 때마다 (적어도 얼마 동안) 다른 것들을 만날 것입니다.
public partial class _008Test : PhoneApplicationPage
{
private List<Question> questionList;
int currentQuestionIndex = 0;
private Question currentQuestion;
int Score = 0;
public _008Test()
{
InitializeComponent();
InitializeComponent();
questionList = new List<Question>();
questionList.Add(new Question { Text = "This is the first question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the second question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the third question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the forth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the fifth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the sixth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the seventh question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the eitht question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the ninth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the tenth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the first question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the second question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the third question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the forth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the fifth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the sixth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the seventh question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the eitht question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
questionList.Add(new Question { Text = "This is the ninth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 1 });
questionList.Add(new Question { Text = "This is the tenth question", Answers = new List<string> { "A", "B", "C", "D" }, CorrectAnswer = 2 });
loadquestion(currentQuestionIndex);
}
private void loadquestion(int questionindex)
{
currentQuestion = questionList[questionindex];
}
private void Next_Click(object sender, System.EventArgs e)
{
Score++;
currentQuestionIndex++;
if (currentQuestionIndex < questionList.Count)
{
loadquestion(currentQuestionIndex);
}
else
{
MessageBox.Show("You have finished!" + "Score is: " + Score);
}
}
}
위의 목록은 20 텍스트를 포함 할 수 있습니다 이 내 코드입니다. 100 개 또는 그 이상으로 만들고 싶습니다. 그러나 나는 모든 것을 보여줄 수 있습니다. 나는 어떻게 10을 말로 표현할 것인가. 따라서 다른 텍스트 세션을 시작하려면 페이지를 다시 열어야합니다.
와 수정을 표시하려면? – Tony
Windows 전화 앱입니다. 실버 라이트. wpf를 사용하지 않습니다. –