I’m trying to navigate to a XAML page from WP Monogame app. Everything works well, but when on-screen keyboard is shown (after touching a textbox) it crashes with the following exception:
{System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Controls.SipHelper.AdjustFrame(FrameworkElement element, Double bottomMargin, Double& stillObscured)
at System.Windows.Controls.SipHelper.FlickIn(FrameworkElement element, Double bottomMargin)
at Microsoft.Phone.Controls.PhoneApplicationPage.SipAndNavBarChange()
at Microsoft.Phone.Controls.PhoneApplicationPage.set_VisibleRegionInPhysicalPixels(RECT value)
at Microsoft.Phone.Controls.PhoneApplicationPage.UpdateCurrentVisualState()
at Microsoft.Phone.Controls.PhoneApplicationPage.HandleVisibleRegionChange()
at Microsoft.Phone.Controls.PhoneApplicationPage.OnVisibleRegionChange()
at Microsoft.Phone.TaskModel.Interop.Task.FireOnVisibleRegionChange()}
I’m navigating to XAML page as follows:
MainPage.xaml contains the following parameters and function:
UIElement savedVisual;
private TestPage ap; // This is the XAML form with some text and TextBox field
public void ShowXamlForm()
{
savedVisual = App.Current.RootVisual;
ap = new TestPage();
App.Current.RootVisual = ap;
}
Actual Game class contains this call:
Deployment.Current.Dispatcher.BeginInvoke(() => mainPage.ShowXamlForm());
mainPage variable is referring to the MainPage object.
I’m on a really thin ice here, took some code snippets here and there and I’m probably doing something wrong. Does anyone have any ideas of how to avoid crashing?