private void ActivateEditTextImpl() { var pane = Windows.UI.ViewManagement.InputPane.GetForCurrentView(); if (pane.TryShow()) { var game = GetGame(); if (game == null) throw new ArgumentException("Provided services need to contain a provider for the IGame interface."); Debug.Assert(game.Context is GameContextUWP, "There is only one possible descendant of GameContext for Windows Store."); gameContext = (GameContextUWP)game.Context; var swapChainPanel = gameContext.Control; // Detach previous EditText (if any) if (activeEditText != null) activeEditText.IsSelectionActive = false; activeEditText = this; // Make sure it doesn't have a parent (another text box being edited) editText = gameContext.EditTextBox; editText.Text = text; swapChainPanel.Children.Add(new Windows.UI.Xaml.Controls.StackPanel { Children = { editText } }); editText.TextChanged += EditText_TextChanged; editText.KeyDown += EditText_KeyDown; // Focus editText.Focus(Windows.UI.Xaml.FocusState.Programmatic); } }
private void ActivateEditTextImpl() { var pane = Windows.UI.ViewManagement.InputPane.GetForCurrentView(); if (pane.TryShow()) { var game = GetGame(); if (game == null) { throw new ArgumentException("Provided services need to contain a provider for the IGame interface."); } Debug.Assert(game.Context is GameContextUWP, "There is only one possible descendant of GameContext for Windows Store."); gameContext = (GameContextUWP)game.Context; var swapChainPanel = gameContext.Control; // Detach previous EditText (if any) if (activeEditText != null) { activeEditText.IsSelectionActive = false; } activeEditText = this; // Make sure it doesn't have a parent (another text box being edited) editText = gameContext.EditTextBox; editText.Text = text; swapChainPanel.Children.Add(new Windows.UI.Xaml.Controls.StackPanel { Children = { editText } }); editText.TextChanged += EditText_TextChanged; editText.KeyDown += EditText_KeyDown; // Focus editText.Focus(Windows.UI.Xaml.FocusState.Programmatic); } }