Search code examples
c#wpfxamlwin-universal-appmonogame

How to navigate from .cs file to .xaml in Monogame?


I have a problem when trying to navigate in a Windows Universal application. Wanting to navigate from a .cs file to a .xaml using the mouse click, the application stops. By using touch the application works, but using click does not work.

My code is as follows (SexAppRetos.cs):

// Mitos
                if ( mitsTrues.Contains( mouseX, mouseY ) ) {
                    var ccc = new Frame();
                    ccc.Navigate( typeof( Credits ) );

                    Window.Current.Content = ccc;
                    Window.Current.Activate();
                }

                // Ayuda cerca de ti
                if ( help.Contains( mouseX, mouseY ) ) {
                    var rootFrame = new Frame();
                    rootFrame.Navigate( typeof( Help ) );

                    Window.Current.Content = rootFrame;
                    Window.Current.Activate();
                }

                // Faqs
                if ( faqs.Contains( mouseX, mouseY ) ) {
                    var rootFrame = new Frame();
                    rootFrame.Navigate( typeof( FaqPage ) );

                    Window.Current.Content = rootFrame;
                    Window.Current.Activate();
                }

Solution

  • The solution is change Mouse click from pressed to released.

    game.mouseState.LeftButton == ButtonState.Pressed
    

    to

    game.mouseState.LeftButton == ButtonState.Released