WinUI

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfBarcode

    Show / Hide Table of Contents

    Class SfBarcode

    The SfBarcode control class is used to encode the text as bar code in a machine-readable format. It provides a perfect approach to encode text using supported symbology types.

    Inheritance
    System.Object
    SfBarcode
    Implements
    System.IDisposable
    Namespace: Syncfusion.UI.Xaml.Barcode
    Assembly: Syncfusion.Barcode.WinUI.dll
    Syntax
    public class SfBarcode : Control, IDisposable
    Examples
    <syncfusion:SfBarcode Width="190" Height="200" Value="1010111011">
         <syncfusion:SfBarcode.Symbology>
              <syncfusion:Code11Barcode/>
         </syncfusion:SfBarcode.Symbology>
    </syncfusion:SfBarcode>
    using Syncfusion.UI.Xaml.Barcode
    …
    SfBarcode sfBarcode = new SfBarcode();
    sfBarcode.Value = "1010111011";
    sfBarcode.Symbology = new Code11Barcode();

    Constructors

    SfBarcode()

    Initializes BarcodeControl class.

    Declaration
    public SfBarcode()

    Fields

    AutoModuleProperty

    Identifies the AutoModule dependency property

    Declaration
    public static readonly DependencyProperty AutoModuleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for AutoModule.

    Remarks

    The identifier for the AutoModule dependency property.

    HorizontalTextAlignmentProperty

    Identifies the HorizontalTextAlignment dependency property.

    Declaration
    public static readonly DependencyProperty HorizontalTextAlignmentProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for HorizontalTextAlignment.

    Remarks

    The identifier for the HorizontalTextAlignment dependency property.

    ModuleProperty

    Identifies the Module dependency property

    Declaration
    public static readonly DependencyProperty ModuleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for Module.

    Remarks

    The identifier for the Module dependency property.

    RotationAngleProperty

    Identifies the RotationAngle dependency property.

    Declaration
    public static readonly DependencyProperty RotationAngleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for RotationAngle.

    Remarks

    The identifier for the RotationAngle dependency property.

    ShowValueProperty

    Identifies the ShowValue dependency property.

    Declaration
    public static readonly DependencyProperty ShowValueProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for ShowValue.

    Remarks

    The identifier for the ShowValue dependency property.

    SymbologyProperty

    Identifies the Symbology dependency property.

    Declaration
    public static readonly DependencyProperty SymbologyProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for Symbology.

    Remarks

    The identifier for the Symbology dependency property.

    TextSpacingProperty

    Identifies the TextSpacing dependency property.

    Declaration
    public static readonly DependencyProperty TextSpacingProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for TextSpacing.

    Remarks

    The identifier for the TextSpacing dependency property.

    ValueProperty

    Identifies the Value dependency property.

    Declaration
    public static readonly DependencyProperty ValueProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for Value.

    Remarks

    The identifier for the Value dependency property.

    VerticalTextAlignmentProperty

    Identifies the VerticalTextAlignment dependency property.

    Declaration
    public static readonly DependencyProperty VerticalTextAlignmentProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    Dependency Property for VerticalTextAlignment.

    Remarks

    The identifier for the VerticalTextAlignment dependency property.

    Properties

    AutoModule

    Gets or sets the value that decides whether the QRBarcode and DataMatrixBarcode needs to be render on available size.

    Declaration
    public bool AutoModule { get; set; }
    Property Value
    Type Description
    System.Boolean

    If we set true then QRBarcode and DataMatrixBarcode will be rendered based on available size.

    HorizontalTextAlignment

    Gets or sets the horizontal alignment of the Value property.

    Declaration
    public TextAlignment HorizontalTextAlignment { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.TextAlignment

    The default value is Microsoft.UI.Xaml.TextAlignment.Center. Fields:

    EnumerationDescription.
    Microsoft.UI.Xaml.TextAlignment.CenterText is centered to the SfBarcode element.
    Microsoft.UI.Xaml.TextAlignment.LeftText is aligned to the left edge of the SfBarcode element.
    Microsoft.UI.Xaml.TextAlignment.RightText is aligned to the right edge of the SfBarcode element.
    Microsoft.UI.Xaml.TextAlignment.EndEnd of the text is aligned to the edge of the SfBarcode element.
    Microsoft.UI.Xaml.TextAlignment.JustifyText is justified with the SfBarcode element.
    Microsoft.UI.Xaml.TextAlignment.StartBeginning of the text is aligned to the edge of the SfBarcode element.
    Microsoft.UI.Xaml.TextAlignment.DetectFromContentText alignment is inferred from the Value content.
    See Also
    VerticalTextAlignment

    Module

    Gets or sets the size of the narrowest bar or smallest dot in the SfBarcode control.

    Declaration
    public double Module { get; set; }
    Property Value
    Type Description
    System.Double

    The value is in pixel and the default value is 2.

    Remarks

    Both the one dimensional and the two dimensional symbology supports the Module property.

    RotationAngle

    Gets or sets the angle in which SfBarcode should be rotated.

    Declaration
    public BarcodeRotation RotationAngle { get; set; }
    Property Value
    Type Description
    BarcodeRotation

    The default value is Angle0. Fields:

    EnumerationDescription
    Angle180 The SfBarcode control is rotated by 180 degree.
    Angle270 The SfBarcode control is rotated by 270 degree.
    Angle90 The SfBarcode control is rotated by 90 degree.
    Angle0 The SfBarcode control is rotated by 0 degree.

    ShowValue

    Gets or sets a value to decide whether Value can be displayed along with the barcode rendered.

    Declaration
    public bool ShowValue { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if text is displayed at the bottom of the barcode; otherwise, false. The default value is false.

    Remarks

    The alignment of the value can be adjusted using HorizontalTextAlignment and VerticalTextAlignment. The spacing between the Value and barcode element will be handled by TextSpacing property.

    Symbology

    Gets or sets the instance of BarcodeBase that will be used to encode the input value to the visual barcode representation.

    Declaration
    public BarcodeBase Symbology { get; set; }
    Property Value
    Type Description
    BarcodeBase

    The default value is null. An instance of BarcodeBase. List of available Barcode settings derived from BarcodeBase:

    ClassDerived classCustomization properties
    • Code11Barcode
    • CodabarBarcode
    • Code128ABarcode
    • Code128BBarcode
    • Code128CBarcode
    • Code32Barcode
    • Code39Barcode
    • UpcBarcode
    • Code39ExtendedBarcode
    • Code93Barcode
    • Code93ExtendedBarcode
    • DataMatrixBarcode
    • QRBarcode
    UnidimensionalBarcode
    • EnableCheckSum
    • ShowCheckSum
    • EncodeStartStopSymbols
    BidimensionalBarcode
    1. DataMatrixBarcode
      • Encoding
      • MatrixSize
    2. QRBarcode
      • ErrorCorrectionLevel
      • InputMode
      • QRVersion

    TextSpacing

    Gets or sets the space between SfBarcode element and the Value.

    Declaration
    public double TextSpacing { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 0.

    Remarks

    The value is in pixel. Based on space, the barcode height is reduced.

    See Also
    HorizontalTextAlignment
    VerticalTextAlignment

    Value

    Gets or sets the value of the SfBarcode to be rendered, which is displayed below the Barcode element when ShowValue property is enabled.

    Declaration
    public string Value { get; set; }
    Property Value
    Type Description
    System.String

    The default value is Null. The following table represent the text that can be given for different barcode types which is required to generate a barcode.

    Symbology typeAccepted characters
    CodabarBarcodeThe supported characters are: [0-9]; [- $ : / . +].
    Code11BarcodeThe supported characters are: [0-9]; [-].
    Code128ABarcodeThe supported characters are [0-9]; [A-Z]; [NUL(0x00) SOH(0x01) STX(0x02) ETX(0x03) EOT(0x04) ENQ(0x05) ACK(0x06) BEL(0x07) BS(0x08) HT(0x09) LF(0x0A) VT(0x0B) FF(0x0C) CR(0x0D) SO(0x0E) SI(0x0F) DLE(0x10) DC1(0x11) DC2(0x12) DC3(0x13) DC4(0x14) NAK(0x15) SYN(0x16) ETB(0x17) CAN(0x18) EM(0x19) SUB(0x1A) ESC(0x1B) FS(0x1C) GS(0x1D) RS(0x1E) US(0x1F) SPACE(0x20)].
    Code128BBarcodeThe supported characters are [0-9]; [A-Z]; [a-z].
    Code128CBarcodeThe supported characters are ASCII 00-99(encodes each two digit with one code). It encodes only numeric symbols at double density, each pair of digits is encoded using a single symbol.
    Code32BarcodeThe supported characters are [0-9]. The barcode length is 9 digits (8 user defined digits + 1 check digit).
    Code39BarcodeThe supported characters are [0-9]; [A-Z]; [- . $ / + % SPACE].
    Code39ExtendedBarcodeThe supported characters are 128 full ASCII characters.
    Code93BarcodeThe supported characters are [0-9]; [A-Z]; [- . $ / + % SPACE].
    Code93ExtendedBarcodeThe supported characters are 128 full ASCII characters.
    UpcBarcodeThe supported characters are [0-9] and text length should be 11 or 12.
    DataMatrixBarcodeThe supported characters are 128 full ASCII characters.
    QRBarcodeThe supported characters are [0–9]; [A–Z (upper-case only)]; [space $ % * + - . / , :]; [Shift JIS characters].
    Remarks

    The Value property is displayed below the Barcode element. The value is accepted as string and encoded in machine readable format. The spacing between the Value and barcode element is handled by TextSpacing property.

    See Also
    ShowValue

    VerticalTextAlignment

    Gets or sets the vertical alignment of the Value property.

    Declaration
    public VerticalAlignment VerticalTextAlignment { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.VerticalAlignment

    The default value is Microsoft.UI.Xaml.VerticalAlignment.Bottom. Fields:

    EnumerationDescription
    Microsoft.UI.Xaml.VerticalAlignment.BottomText will be displayed below the SfBarcode element.
    Microsoft.UI.Xaml.VerticalAlignment.TopText will be displayed above the SfBarcode element.
    Microsoft.UI.Xaml.VerticalAlignment.CenterText will be displayed below the SfBarcode element with center aligned.
    Microsoft.UI.Xaml.VerticalAlignment.StretchText will be stretched to fill the entire layout of the SfBarcode element.
    See Also
    HorizontalTextAlignment

    Methods

    Dispose()

    Dispose Method for SfBarcode class.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Helps in releasing the unwanted resources and dispose the control instance.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    Returns true when control is disposed

    MeasureOverride(Size)

    Adjusts the size of the control based on value change.

    Declaration
    protected override Size MeasureOverride(Size availableSize)
    Parameters
    Type Name Description
    Windows.Foundation.Size availableSize

    Gets the size to calculate Barcode Text Element

    Returns
    Type Description
    Windows.Foundation.Size

    Returns Barcode with Text Element size

    OnApplyTemplate()

    Applies control template.

    Declaration
    protected override void OnApplyTemplate()

    OnCreateAutomationPeer()

    Declaration
    protected override AutomationPeer OnCreateAutomationPeer()
    Returns
    Type Description
    Microsoft.UI.Xaml.Automation.Peers.AutomationPeer

    Implements

    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved