Wie gehen Sie zu einem anderen Bildschirm von einem Bildschirm in Xamarin cross-Plattform?

Ich bin neu in Xamarin und ich wollen gehen Sie zu einem anderen Bildschirm an einem Bildschirm. Ich habe eine Taste im ersten Bildschirm, und ich will es öffnet sich ein weiterer Bildschirm nach dem klicken auf die Schaltfläche.
Wie kann ich dies tun?

Hier ist der code, den ich bisher versucht habe:

XAML-Layout (FirstXAML.xaml)

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="AllControlsDemo.FirstXaml">



<StackLayout>
    <Slider x:Name="sldr" 
      VerticalOptions="CenterAndExpand"
            ValueChanged="OnSliderValueChanged" />

<Label x:Name="lblValue"
       Text="A simple Label"
       Font="Large"
       HorizontalOptions="Center"
       VerticalOptions="CenterAndExpand" />

    <Button x:Name="btnClickme"
         Text="Click Me!"
            HorizontalOptions="Center"
            VerticalOptions="CenterAndExpand"
            Clicked="OnbtnClickme" />


    <Button x:Name="btnSecondXaml"
         Text="Second Xaml!"
            HorizontalOptions="Center"
            VerticalOptions="StartAndExpand"
            Clicked="OnbtnSecondXaml" />

  </StackLayout>
</ContentPage>

Code (FirstXAML.xaml.cs)

using System;
using System.Collections.Generic;
using Xamarin.Forms;


namespace AllControlsDemo
{ 
    public partial class FirstXaml : ContentPage
    { 

  private Label valueLabel;
  float count = 0.050f;
  private Slider slider;



public FirstXaml ()
  {
   InitializeComponent ();
   valueLabel = this.FindByName<Label>("lblValue");
   slider = this.FindByName<Slider> ("sldr");

  }



void OnSliderValueChanged(object sender, ValueChangedEventArgs args)
  {
   valueLabel.Text = ((Slider)sender).Value.ToString("F3");
   count = float.Parse(valueLabel.Text);
  }



void OnbtnClickme(object sender, EventArgs args)
  {
   count += 0.050f;
   slider.Value = count;
  }



void OnbtnSecondXaml(object sender, EventArgs args)
  {
   //Write code here to move on second Xaml 

  }



}
}

InformationsquelleAutor Ashish Tiwari | 2014-11-28

Schreibe einen Kommentar