.NET MAUI QR Code Scanner
Introduction
.NET MAUI (.NET Multi-platform App UI) is a cross-platform framework for building native mobile and desktop applications from a single C# codebase. A single project can target Android, iOS, macOS, and Windows, sharing UI layouts and business logic across all platforms. MAUI's integration with the .NET ecosystem means developers can reach mobile users without abandoning familiar tooling or languages.
In this article, we'll explain how to build a native QR code scanner in a .NET MAUI application using IronQR to decode QR codes selected from the device's photo library.
How to Build a QR Code Scanner in .NET MAUI
- Install the IronQR C# library to scan QR codes on mobile
- Design the application layout in
MainPage.xaml - Use
FilePickerto let the user select a QR code image from the device - Load the image and wrap it in a
QrImageInput - Call
Readand display the decoded value in aLabel
IronQR: C# QR Code Library
To read QR codes in the application, we'll use the IronQR .NET library. It provides a straightforward API for detecting and decoding QR codes from any image source, including files selected on a mobile device. IronQR runs on all MAUI target platforms and requires no barcode domain knowledge to integrate.
IronQR can decode standard QR codes, Micro QR codes, and rMQR codes, and accepts image input as files, streams, or bitmaps. It can be installed in seconds via the NuGet Package Manager.
Steps to Build a QR Code Scanner in .NET MAUI
Follow these steps to add QR code scanning to a .NET MAUI application.
Prerequisites
- Visual Studio 2022 with the .NET MAUI workload installed
- A .NET MAUI project targeting Android or iOS
Install IronQR
Install the IronQR library using the NuGet Package Manager Console in Visual Studio. Navigate to Tools > NuGet Package Manager > Package Manager Console and run:
Install-Package IronQR
Alternatively, search for IronQR on NuGet and install the latest version.
Front-End Design
The scanner UI consists of a button to trigger image selection, an image view to preview the selected QR code, and a label to display the decoded result.
Replace the content of MainPage.xaml with the following:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiQrScanner.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Button
x:Name="scanButton"
Text="Select QR Code Image"
SemanticProperties.Hint="Select Image"
Clicked="OnScanButtonClicked"
HorizontalOptions="Center" />
<Image
x:Name="qrImage"
SemanticProperties.Description="Selected QR Code"
HeightRequest="200"
HorizontalOptions="Center" />
<Label
x:Name="resultLabel"
Text="Scanned Text: "
HorizontalOptions="Center"
VerticalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiQrScanner.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Button
x:Name="scanButton"
Text="Select QR Code Image"
SemanticProperties.Hint="Select Image"
Clicked="OnScanButtonClicked"
HorizontalOptions="Center" />
<Image
x:Name="qrImage"
SemanticProperties.Description="Selected QR Code"
HeightRequest="200"
HorizontalOptions="Center" />
<Label
x:Name="resultLabel"
Text="Scanned Text: "
HorizontalOptions="Center"
VerticalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Sample Input
Use the QR code below as a test image. Save it to your device, then select it through the app's file picker. The decoded value should display as https://ironsoftware.com.
Sample QR code — encodes https://ironsoftware.com
QR Code Scanning with IronQR
When the scan button is tapped, FilePicker opens the device's image library. After the user selects a photo, the full path is loaded into an AnyBitmap, which is passed to QrReader.Read(). The decoded value from the first detected QR code is displayed in the result label.
Add the following method to MainPage.xaml.cs:
using IronQr;
using IronSoftware.Drawing;
private async void OnScanButtonClicked(object sender, EventArgs e)
{
// Start scanning QR codes
var images = await FilePicker.Default.PickAsync(new PickOptions
{
PickerTitle = "Pick image",
FileTypes = FilePickerFileType.Images
});
var imageSource = images.FullPath.ToString();
var inputBmp = AnyBitmap.FromFile(imageSource);
// Load the asset into QrImageInput
QrImageInput imageInput = new QrImageInput(inputBmp);
// Create a QR Reader object
QrReader reader = new QrReader();
// Read the input and get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
// Display the first result
resultLabel.Text = "Scanned Text: " + results.First().Value;
}
using IronQr;
using IronSoftware.Drawing;
private async void OnScanButtonClicked(object sender, EventArgs e)
{
// Start scanning QR codes
var images = await FilePicker.Default.PickAsync(new PickOptions
{
PickerTitle = "Pick image",
FileTypes = FilePickerFileType.Images
});
var imageSource = images.FullPath.ToString();
var inputBmp = AnyBitmap.FromFile(imageSource);
// Load the asset into QrImageInput
QrImageInput imageInput = new QrImageInput(inputBmp);
// Create a QR Reader object
QrReader reader = new QrReader();
// Read the input and get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
// Display the first result
resultLabel.Text = "Scanned Text: " + results.First().Value;
}
Imports IronQr
Imports IronSoftware.Drawing
Private Async Sub OnScanButtonClicked(sender As Object, e As EventArgs)
' Start scanning QR codes
Dim images = Await FilePicker.Default.PickAsync(New PickOptions With {
.PickerTitle = "Pick image",
.FileTypes = FilePickerFileType.Images
})
Dim imageSource = images.FullPath.ToString()
Dim inputBmp = AnyBitmap.FromFile(imageSource)
' Load the asset into QrImageInput
Dim imageInput As New QrImageInput(inputBmp)
' Create a QR Reader object
Dim reader As New QrReader()
' Read the input and get all embedded QR Codes
Dim results As IEnumerable(Of QrResult) = reader.Read(imageInput)
' Display the first result
resultLabel.Text = "Scanned Text: " & results.First().Value
End Sub
FilePicker.Default.PickAsync is provided by the MAUI platform abstraction layer and works on Android, iOS, and Windows without any platform-specific code. AnyBitmap.FromFile handles image decoding, and QrReader.Read returns an IEnumerable<QrResult> with one entry per QR code found in the image.
Output
Selecting a QR code image triggers the scan. The decoded value appears in the result label below the image preview.
QR code selected and decoded value displayed in the result label
Download the Project
Conclusion
In this article, we demonstrated how to build a native QR code scanner in a .NET MAUI application using IronQR. The FilePicker API provides platform-native image selection on Android, iOS, and Windows, while IronQR's QrReader.Read handles the decoding in a single call. The same approach scales to multiple QR codes per image by iterating over the full results collection instead of calling .First().
IronQR requires a license for development and commercial use. Licensing details are available here.
For a deeper look at reading QR code properties beyond the value, see the Read QR Code Value and Read QR Code Type guides.
Frequently Asked Questions
What is the .NET MAUI QR Code Scanner Tutorial about?
The .NET MAUI QR Code Scanner Tutorial provides guidance on building a QR code scanner using IronQR, with instructions tailored for .NET MAUI applications on Android, iOS, and Windows platforms.
Which platforms are supported by the .NET MAUI QR Code Scanner?
The .NET MAUI QR Code Scanner supports Android, iOS, and Windows platforms, allowing developers to create cross-platform applications using IronQR.
How can I select images for QR code scanning in a .NET MAUI application?
You can use the FilePicker component in a .NET MAUI application to select images, which can then be processed by IronQR's QrReader.Read() method to decode QR codes.
What function is used to decode QR codes in the tutorial?
In the tutorial, the QrReader.Read() function from IronQR is used to decode QR codes from selected images in a .NET MAUI application.
Can I use IronQR for QR code scanning in a cross-platform application?
Yes, IronQR is designed to be used in cross-platform applications, and with the .NET MAUI framework, you can create QR code scanners for Android, iOS, and Windows.
Is there a specific QR code reader function for .NET MAUI?
Yes, the tutorial demonstrates how to use the QrReader.Read() function from IronQR within a .NET MAUI application to read and decode QR codes.
Does IronQR support QR code scanning on mobile devices?
IronQR supports QR code scanning on mobile devices, including Android and iOS, as demonstrated in the .NET MAUI QR Code Scanner Tutorial.
What is the role of FilePicker in the QR code scanning process?
FilePicker is used to select images from the device storage, which are then passed to IronQR's QrReader.Read() for QR code decoding in a .NET MAUI application.
Is it possible to integrate a QR code scanner into a Windows application using .NET MAUI?
Yes, the .NET MAUI QR Code Scanner Tutorial shows how to integrate a QR code scanner into a Windows application using IronQR.

