Set main page to shell page error
Issac
0
Reputation points
At beginning, set MainPage to an Content Page
public App()
{
Debug.WriteLine("App");
InitializeComponent();
//SvgImageSource.RegisterAssembly();
MainPage = new IndexPage();
}
afterwards, try to switch to another shell page
async void NavigateHomePage()
{
Application.Current.MainPage = new AppShell();
}
[AndroidRuntime] java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference
[AndroidRuntime] at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3582)
[AndroidRuntime] at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3581)
[AndroidRuntime] at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3581)
[AndroidRuntime] at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3581)
[AndroidRuntime] at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3581)
[AndroidRuntime] at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3581)
[AndroidRuntime] at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3555)
[AndroidRuntime] at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2976)
[AndroidRuntime] at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10422)
[AndroidRuntime] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1671)
[AndroidRuntime] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1680)
[AndroidRuntime] at android.view.Choreographer.doCallbacks(Choreographer.java:1191)
[AndroidRuntime] at android.view.Choreographer.doFrame(Choreographer.java:1063)
[AndroidRuntime] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1650)
[AndroidRuntime] at android.os.Handler.handleCallback(Handler.java:958)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:99)
[AndroidRuntime] at android.os.Looper.loopOnce(Looper.java:222)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:314)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:8658)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:565)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
**Java.Lang.NullPointerException:** 'Loading...'
However, if I set an ContentPage to MainPage, it works.
async void NavigateHomePage()
{
Application.Current.MainPage = new MainPage();
}
Also, if I did something, such as
Action<string> callback = o =>
{
Application.Current.MainPage = new AppShell();
}
};
await this.Navigation.PushModalAsync(new NavigationPage(new AboutUsWebView(url, title, callback)), false);
It works...................... Please help,
Developer technologies | .NET | .NET MAUI
Developer technologies | .NET | .NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Sign in to answer