Use a software trigger with a barcode scanner

This topic explains how to control the barcode scanning process programmatically using an asynchronous software trigger.

It can be useful to control the act of scanning from software if you are using a barcode scanner in presentation mode or if the scanner does not have a physical trigger such as a camera-based barcode scanner. You can initiate the scan process by calling StartSoftwareTriggerAsync.

Depending on the value of IsDisabledOnDataReceived the scanner may scan only one barcode then stop or scan continuously until you call StopSoftwareTriggerAsync.

Set the desired value of IsDisabledOnDataReceived to control the scanner behavior when a barcode is decoded.

Value Description
True Scan only one barcode then stop
False Continuously scan barcodes without stopping

Important

Confirm that your barcode scanner supports the use of software trigger by first checking the property IsSoftwareTriggerSupported.

The following example shows how to initiate scanning using a software trigger, which will stop scanning once it scans one barcode:

private void SoftwareTrigger(BarcodeScanner barcodeScanner, ClaimedBarcodeScanner claimedBarcodeScanner) 
{
    if (barcodeScanner.Capabilities.IsSoftwareTriggerSupported)
    {
        claimedBarcodeScanner.IsDisabledOnDataReceived = true;
        await claimedBarcodeScanner.StartSoftwareTriggerAsync();
    }
}

Support and feedback

Find answers to your questions

Have questions? Ask us on either our Docs Q&A forum with the UWP tag or on Stack Overflow with the pointofservice tag.

Help us locate your questions:

  • Add the pointofservice tag to your question on Stack Overflow.
  • Include the "UWP" term in your post on the Q&A forum