2011-07-02 6 views
1

私はクイズプログラムを作ろうとしています。私はリストに答えがあり、各質問のポップアップ・ボックスを作成しようとしています。ユーザーは選択肢を作ってから、次のポップアップ・質問に行きます。私はテストの場合に行うボタンやボックスにポップアップウィンドウをループする

public partial class Test 

{ 

Popup p = new Popup(); 

    public Test() 

    { 

    InitializeComponent(); 
    testvalues = GetQuestions(); 

    int numberofquestions; 
    numberofquestions = testvalues.Count/6; 

    for (int i = 0; i < numberofquestions; i++) 
    { 
    runtest(i, numberofquestions); 
    } 
    } 

    private void runtest(int questionnumber,int numberofquestions) 
    { 

    StackPanel testpanel = new StackPanel(); 
    TextBlock textblockquestion = new TextBlock(); 
    TextBlock textblockscore = new TextBlock(); 

    RadioButton buttona = new RadioButton(); 
    RadioButton buttonb = new RadioButton(); 
    RadioButton buttonc = new RadioButton(); 
    RadioButton buttond = new RadioButton(); 

....何とか何とか何とかフィルもの...

testpanel.Children.Add(textblockscore); 
    testpanel.Children.Add(textblockquestion); 
    testpanel.Children.Add(buttona); 
    testpanel.Children.Add(buttonb); 
    testpanel.Children.Add(buttonc); 
    testpanel.Children.Add(buttond); 
    border.Child = testpanel; 

    p.Child = border; 
    p.IsOpen = true; 

....何とか何とか何とか:

はここに私のC#です彼らが選択したボタンが正解に対応しているかどうかを確認してください。 たとえば、if文に応じて4つのボタンのそれぞれについて次のようなものがあります。

(if right) 
    buttonb.Click += new RoutedEventHandler(Right_Click); 
    else 
    buttonb.Click += new RoutedEventHandler(Wrong_Click); 

    } 

    void Wrong_Click(object sender, RoutedEventArgs e) 
    { 
    countwrong++; 
    p.IsOpen = false; 
    } 

    void Right_Click(object sender, RoutedEventArgs e) 
    { 
    countright++; 
    p.IsOpen = false; 
    } 

} 

今すぐプログラムは、最初のポップアップボックスを表示します。私は答えの選択肢をクリックし、ポップアップ・ボックスを閉じてから何もしない。なぜ私のforループで次のポップアップボックスを作成するのが始まっていないのか分かりません。私のコードの編成に何か問題がありますか、それとも構文の問題ですか?ポップアップを小さなステップに分割する必要はありますか?

答えて

0

ポップアップが実際に終了していない可能性があります。ループの代わりに、現在のポップアップの閉じたイベントで次のポップアップを開こうとしましたか?

私はあなたを助けることができる何か、少なくとも、私はそれがあなたの質問に正確な答えはありません知っているが、それが役立つことがわかりました。私は必要なものではなかったHow to close popup in silverlight?

+0

いいえ。私は最終的に私のコードを再構成しなければならなかった。 Right_ClickとWrong_Clickサブルーチンの中に "runtest"の呼び出しを入れ、forループを削除しました。このようにラジオボタンをクリックすると、次の質問が生成されます。 –

関連する問題