Reputation: 41
I've just created 2 pages (MainPage and ScanningPage).I would like to Naviage from MainPage to ScanningPage. Then after scanning is completed I'd like to go back to MainPage with scanner.barcode value. Any advices?
Thank you in Advance
This is how I navigate from MainPage to ScaningPage:
public partial class MainPage : ContentPage
{
private string barcodeValue;
private ScanningPage scanner = new ScanningPage();
public MainPage()
{
InitializeComponent();
barcodeValue = "";
}
async private void UrlButton_Clicked(object sender, EventArgs e)
{
await Navigation.PushAsync(scanner);
await Navigation.PopAsync();
scannResultText.Text = scanner.barcode;
}
}
ScanningPage:
public partial class ScanningPage : ContentPage
{
public string barcode = "";
public ScanningPage()
{
InitializeComponent();
}
private void _scanView_OnScanResult(ZXing.Result result)
{
Device.BeginInvokeOnMainThread(async () =>
{
//await DisplayAlert("Scanned result", result.Text, "OK");
barcode = result.Text;
});
}
}
Upvotes: 0
Views: 143
Reputation: 252
To Navigate to the Scanning page, you can use:
Navigation.PushAsync(new ScanningPage());
Once you're done on the Scanning Page, you can return to the original page by calling:
Navigation.PopAsync();
Upvotes: 2