0

int buttonCount を使用して、別のページのリストボックスに追加しようとしています。public static int buttonCount = 15; を使用しました。ButtonCount int を MainPage.xaml.cs で使用できるようにしましたが、highScore.xaml.cs で使用しようとすると表示されないようです。私の名前空間は Potato_v2 で、クラスはページの名前です。これがgamePageの私のコードの一部です。

    public static int buttonCount = 0;
    string stringButtonCount = "";
    Random rnd = new Random();
    int count = 15;



    void countDownTimerEvent(object sender, EventArgs e)
   {
    txtCountdown.Text = count + " Seconds Remaining";


        if (count > 0)
        {
        count--;
        }
        if (count == 0)
        {
            countDownTimer.Stop();
            NavigationService.Navigate(new Uri("/highScore.xaml", UriKind.Relative));
            count = 15;
            buttonCount = 0;
            stringButtonCount = "";
        }

   }

MainPage のコード: 何らかの理由で最初の行を取得できません。

private void newToDoAddButton_Click(オブジェクト送信者, RoutedEventArgs e)

    {
        ToDoItem newToDo = new ToDoItem { ItemName = newToDoTextBox.Text };
        ToDoItems.Add(buttonCount);
        toDoDB.ToDoItems.InsertOnSubmit(newToDo);

    }
4

1 に答える 1

2

クラス名 (静的メンバー) またはインスタンスなしでは、クラス外の変数にアクセスすることはできません。したがって、この行:

ToDoItems.Add(buttonCount);

次のようにする必要があります。

ToDoItems.Add(ToDoItem.buttonCount);
于 2013-10-25T14:35:12.303 に答える