WP7 - InputPrompt“元素已经是另一个元素的子元素。”

时间:2012-11-21 12:40:42

标签: c# windows-phone-7 xaml messagebox

我有这样的代码:

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(最后一个事件)时?

0 个答案:

没有答案