Navigation Page CS to XAML

I am developing an application in Xamarin of PCL type that mixes different pages (XAML and CS) to navigate within my pages .xaml I have no problems, the problem is when I try to change the .cs page to an .xaml. .. My Application Falls! ... and occupied different Navigation commands but I can not jump from cs ----> xaml

Any help for me?

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Yes,if you post some code

  • fytofyto CLMember ✭✭

    This its my code SelectPrinterPage.cs

    private async void PrintLineModePrinter()
    {
    IConnection connection = null;
    try
    {
    connection = myPrinter.Connection;
    connection.Open();
    IZebraPrinter printer = ZebraPrinterFactory.Current.GetInstance(connection);
    if ((!CheckPrinterLanguage(connection)) || (!PreCheckPrinterStatus(printer)))
    {
    //resetPage();
    return;
    }
    sendZplReceipt(connection);
    if (PostPrintCheckStatus(printer)) ;
    //ShowAlert("Receipt printed.");
    }
    catch (Exception ex)
    {
    // Connection Exceptions and issues are caught here
    await DisplayAlert("Error", ex.Message, "Aceptar");
    }
    finally
    {
    if ((connection != null) && (connection.IsConnected))
    connection.Close();
    }
    }

    Where to enter the navigation command? What command?

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Navigation Command is something like Navigation.PushAsync?

    You can use it where you want.

    If you are inside a ContentPage you can call

    Navigation.PushAsync
    

    If you are not in a ContentPage you can call something like

    Application.Current.MainPage.PushAsync
    
  • fytofyto CLMember ✭✭

    @AlessandroCaliaro

    With the Navigation.PushAsync command my app falls

    And with the Application.Current.MainPage.Navigation.PushAsync (NewInfraccionPage ());

    You can not ... since the NewInfraccionPage page is of type xaml

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    type Xaml? Sorry, really I don't understand the problem. Xaml is only a way to define your UI. You can create your UI with xaml or in code, but with both you have a class. Use this class name to Push your page.

    in your case you should have a NewInfraccionPage.xaml.cs...

  • fytofyto CLMember ✭✭

    My problem is that when I put the command
    Await Navigation.PushAsync (new MenuPage (this.usuariosMovil));

    My app falls ... I attach the MenuPage code as well

    MenuPage.cs:

    namespace SITAppVersion2.Pages
    {
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class MenuPage : ContentPage
    {
    public int UsuarioMovilID;
    private UsuariosMovil usuariosMovil;
    private Infraccion infraccion;

        public MenuPage(UsuariosMovil usuariosMovil)
        {
            InitializeComponent();
    
            this.usuariosMovil = usuariosMovil;           
            //UsuarioMovilID = usuariosMovil.UsuarioMovilID;
            titleLabel.Text = string.Format("[email protected] {0} {1}", usuariosMovil.Nombre, usuariosMovil.Apellido);
    
            infraccionButton.Clicked += infraccionButton_Clicked;
            consultarButton.Clicked += consultarButton_Clicked;
    
        }       
    
        private async void consultarButton_Clicked(object sender, EventArgs e)
        {
            await Navigation.PushAsync(new ConsultarPage());
        }
    
    
        private async void infraccionButton_Clicked(object sender, EventArgs e)
        {
            await Navigation.PushAsync(new NewInfraccionPage(this.usuariosMovil));
        }
    
    }
    
  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    What does it means "failed". Do you have an exception? Is that "SIGBART"?

    Android?

    if you add a breakpoint

        this.usuariosMovil = usuariosMovil;           
    

    do you arrive there ?

Sign In or Register to comment.