Version

Adding Barcode In Code-Behind

Before You Begin

This topic is designed to get you up and running as quickly as possible by describing the basic steps required for adding a XamCode128Barcode™ control to your page .

What You Will Accomplish

You will add a basic XamCode128Barcode control to your page .

Follow these Steps

  1. Create a WPF application.

  2. Add the following NuGet package references to your project:

    • Infragistics.WPF.Barcodes

    For more information on setting up the NuGet feed and adding NuGet packages, you can take a look at the following documentation: NuGet Feeds.

  1. Add the following namespaces in the application.

In Visual Basic:

Imports Infragistics.Controls.Barcodes

In C#:

using Infragistics.Controls.Barcodes;
  1. Choose a barcode symbology. To the UserControl_Loaded event handler, add an instance of the chosen xamBarcode symbology naming it Barcode.

Note: Each barcode symbology is a separate control.

XamBarcode Symbology Types:

In Visual Basic:

Dim Barcode As New XamCode128Barcode()

In C#:

var Barcode = new XamCode128Barcode();
  1. Assign a value to the control’s Data property

In Visual Basic:

Barcode.Data = "Code128"

In C#:

Barcode.Data = "Code128";
  1. Add the instance of conrol to the main view.

In Visual Basic:

Me.LayoutRoot.Children.Add(Barcode)

In C#:

this.LayoutRoot.Children.Add(Barcode);
  1. Save and run your application.

xamBarcode Adding Code128 01.png