Skip to main content
A newer version of this page is available. .

BarCodeEdit Class

Allows you to display various barcodes.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v19.1.dll

Declaration

public class BarCodeEdit :
    BaseEdit,
    IFullBarCodeData,
    IBarCodeData,
    IImageExportSettings,
    IExportSettings

Remarks

The BarCodeEdit control is used to display different kinds of barcodes.

bar code edit

Tip

The BarCodeEdit class inherits its features from the BaseEdit class.

Refer to the BaseEdit class description for information on derived features and API.

Create a BarCodeEdit

<Window ...
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">

    <!-- Adds a default BarCodeEdit to your window -->
    <dxe:BarCodeEdit EditValue="http://devexpress.com" >
            <dxe:BarCodeEdit.StyleSettings>
                <dxe:QRCodeStyleSettings CompactionMode="Byte" />
            </dxe:BarCodeEdit.StyleSettings>
        </dxe:BarCodeEdit>
</Window>

Editor Value

To specify the editor’s value, use the BaseEdit.EditValue or BarCodeEdit.BinaryData property.

Use the BinaryData property to code a byte array into the PDF417 or ECC200 bar code (when their CompactionMode is set to Binary).

To respond to changing the editor’s value, handle the BaseEdit.EditValueChanged event.

Barcode Types

The BarCodeEdit control can display 27 barcode types including the widely-used QR, UPC, and Intelligent mail.

To display the barcode of a specific type, set the BarCodeEdit.StyleSettings property value to a corresponding *StyleSettings object. Each StyleSettings object contains properties that allow you to configure a specific barcode type.

The following example demonstrates the configuration of a barcode editor that displays a QR Code.

<dxe:BarCodeEdit AutoModule="True" ShowText="False" EditValue="http://www.devexpress.com">
    <dxe:BarCodeEdit.StyleSettings>
        <dxe:QRCodeStyleSettings CompactionMode="Byte" />
    </dxe:BarCodeEdit.StyleSettings>
</dxe:BarCodeEdit>

Error Correction

QR and PDF417 barcodes have built-in support for error correction.

<dxe:BarCodeEdit AutoModule="True" ShowText="False" EditValue="DevExpress">
    <dxe:BarCodeEdit.StyleSettings>
        <dxe:PDF417StyleSettings ErrorCorrectionLevel="3"/>
    </dxe:BarCodeEdit.StyleSettings>
</dxe:BarCodeEdit>

Barcode Readability

The Module property allows you to customize the width of the narrowest bar or space. If the Module property is set to too small a value, a barcode output may become unreadable by the appropriate barcode scanner.

To better control the Module property value when resizing a barcode, set the BarCodeEdit.AutoModule property to true.

WPF_Barcodes_Module.png

Barcode Text

The barcode editor can display a text specified by the EditValue property. For some barcode types it’s required, for other types it should be hidden. Set the ShowText property to true to display code text.

Use the HorizontalTextAlignment and VerticalTextAlignment properties to align the displayed text.

Example

This example demonstrates how to use BarCodeEdit to display a QR code based on a custom value.

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" x:Class="BarCodeEdit.MainWindow"
        Title="MainWindow" Height="300" Width="250">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="242" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <dxe:BarCodeEdit Grid.Row="0" AutoModule="True" ShowText="False" EditValue="{Binding Path=Text,ElementName=textBox}" >
            <dxe:BarCodeEdit.StyleSettings>
                <dxe:QRCodeStyleSettings CompactionMode="Byte" />
            </dxe:BarCodeEdit.StyleSettings>
        </dxe:BarCodeEdit>
        <TextBox Grid.Row="1" Name="textBox">
            DevExpress
        </TextBox>

    </Grid>
</Window>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BarCodeEdit class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also