1

我有这样的代码:

private InputPrompt input = new InputPrompt();

        public MainPage()
        {
            InitializeComponent();
            Loaded += MainPage_Loaded;
            input.Completed += Input_Completed;
            input.Title = "Počet strků do konce";
            input.Message = "Zadejte počet strků do kterých chcete hrát";
            input.InputScope = new InputScope { Names = { new InputScopeName() { NameValue = InputScopeNameValue.Number } } };

            PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
        }

        void Input_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)
        {
            var input = (InputPrompt)sender;
            appSettings.TextBoxSettingEndPoints = Convert.ToInt16(input.Value);
            pocitadlo = new Counter(appSettings.TextBoxSettingEndPoints);
            LayoutRoot.DataContext = pocitadlo;
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (showPopup)
            {
                ShowPopUp();
            }
        }

        private void ShowPopUp()
        {
            input.Value = appSettings.TextBoxSettingEndPoints.ToString();
            input.Show();
            showPopup = false;
        }
         private void MenuItemNewGame_Click_1(object sender, EventArgs e)
        {
            endOfGame = false;
            pocitadlo.CurrentPoints = 0;
            pocitadlo.AllPoints = 0;
            ShowPopUp();
        }

有人可以帮助我为什么会出现错误:“元素已经是另一个元素的子元素。” 当我点击 menuItem NewGame (最后一个事件)时?

4

0 回答 0