MAUI: Most common pitfalls

1. I received this exception on startup #

**Microsoft.Maui.Platform.HandlerNotFoundException:** 'Handler not found for view Plugin.Maui.Barkoder.Controls.BarkoderView.'

In your MauiProgram.cs you need to configure the MauiHandler using

                    .ConfigureMauiHandlers(handlers =>
    {
        handlers.AddHandler(typeof(BarkoderView), typeof(BarkoderViewHandler));
    });
            

2. Is it possible to use the BarkoderView with an MVVM pattern? #

You can use IBarkoderDelegate in any class you want; it is not limited only to the content page. Although you need to pass BarkoderView as a parameter to start the scanning process. Here is a code snippet you can try

                    using Plugin.Maui.Barkoder.Handlers;
    using Plugin.Maui.Barkoder.Interfaces;
    using Plugin.Maui.Barkoder.Controls;
    namespace BarkoderSample
    {
        public class BarkoderExampleViewModel: IBarkoderDelegate
        {
           BarkoderView BKDView;
           
           public BarkoderExampleViewModel(BarkoderView barkoderView)
           {
               BKDView = barkoderView;
               
               // TODO: - Barkoder configuration goes here or on the ContentPage
           }
           
           public void StartScanning()
           {
               BKDView.StartScanning(this);
           }
           public void DidFinishScanning(BarcodeResult[] result)
           {
               // TODO: - Handle results here and/or pass to ContentPage 
           }
       }
    }
            

3.We want the scanning area to cover the full screen, not just the square region. #

The missing thing you need is SetRegionOfInterest. In your SetBarkoderSettings in your xaml.cs file you can use

                    // Your other settings
    scanner.SetRegionOfInterest(0, 0, 100, 100);
            

This means the ROI will start with 0 from the left and top and fill 100% of the screen

4. Can the MAUI sdk control the scanner timeout? #

                     private void OnStartScanningBtnClicked(object sender, EventArgs e)
        {
           BKDView.StartScanning(this);
           _ = StopScanHandler();
        
       }
       private async Task StopScanHandler()
       {
           await Task.Delay(TimeSpan.FromSeconds(10.5));
           BKDView.StopScanning();
       }
            

5.Can Barkoder expand/convert UPC-E to UPC-A? #

Yes, you can use the method below to achieve that.

                _scanner.SetUPCE1expandToUPCA(true);
_scanner.SetUPCEexpandToUPCA(true);
            

6. It seems that continuous scanning does not respect the thresholdBetweenDuplicateScans setting. #

The functionsetDuplicatesDelayMs has been removed in the latest SDK version. However, you can achieve the same behavior by using SetThresholdBetweenDuplicateScans(10)

Note: This method sets the delay (in seconds) for considering barcodes as duplicates during scanning.

7.In your demo app there are Camera Settings available: #

  • Dynamic Exposure
  • Camera Focus and Exposure
  • Video Stabilization

Are those settings also available for .net Maui ?

Answer - Yes — these settings are also available in the .net MAUI version. You can configure them through the following methods on the BarkoderViewinstance:

                     - BKDView.SetDynamicExposure(int level);

     - BKDView.SetCentricFocusAndExposure(bool enabled);

     - BKDView.SetVideoStabilization(bool enabled);
            

This allows you to adjust camera exposure, focus, and stabilization behavior in your MAUI app, just like in the demo app.

8. 

Page Contents

History:

close