Xamarin.forms: How to programatically modify the value of a displayed Display prompt?

Jean-Baptiste Delvaux 1 Reputation point
2023-09-25T12:23:06.8+00:00

Greetings,

I am using android devices connected with Bluetooth scanners. I am trying to adapt some code without rewriting the entire page to accommodate for it.

Basically, whenever something is scanned, the messaging center detect it and start a particular async function: HandleReadLabel. Within said function, I eventually call for DisplayPromptAsync from Xamarin.forms.core with a numeric only keboard. Whenever I scan a product (AE trigger HandleReadLabel) I would like to increment the quantity written in the DisplayPromptAsync by X. Since I'm using it to scan barcode, I have barcodes that mean "This product x2" or "that product x16" and I want to use that table to know by how many to increment the value.

But I do not know how I can impact the DisplayPrompt's value directly. Thank you for the help and have a nice day

protected override void OnAppearing()
        {
            base.OnAppearing();

            //Refresh list on appearing
            viewModel.LoadItemsCommand.Execute(null);

            //Scanner handler
            MessagingCenter.Unsubscribe<App, string>(this, "Barcode");
            MessagingCenter.Subscribe<App, string>(this, "Barcode", (sender, arg) => {
                Device.BeginInvokeOnMainThread(() =>
                {
                    HandleReadLabel(arg);
                });
            });
		}
public async Task<bool> HandleReadLabel(string labelText)
        {
			var quantityTransfer = await DisplayPromptAsync(viewModel.primaryBin.labelAdresse, $"Quantité Totale ({productLine.quantityOrdered}): ", placeholder: productLine.quantyReceived.ToString(), keyboard: Keyboard.Numeric);                            
			if (quantityTransfer == "Cancel")
		}
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,336 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.