WinUI | ComponentOne
Controls / BarCode / Barcode Options
In This Topic
    Barcode Options
    In This Topic

    The C1BarCode class provides several properties that are common to all barcodes or specific to certain barcodes. These properties are used to customize the appearance of BarCode control.

    The common properties that are available in C1.WinUI.BarCode assembly and can be set easily either using XAML or C# to their predefined values for rendering barcodes are as follows:

    CodeType and Text

    The CodeType property of the C1BarCode class lets you specify encoding that should be applied to the string value stored in the Text property to generate the barcode image. These are the two basic properties required for generating the barcode.

    You can set the CodeType and Text properties using the following code snippet to generate the barcode:

    <BarCode:C1BarCode x:Name="barCode" CodeType="QRCode" Text="ComponentOne@123"></BarCode:C1BarCode>
    
    barCode.CodeType = CodeType.QRCode;
    barCode.Text = "ComponentOne@123";
    

    Alignment

    The C1BarCode class provides HorizontalAlignment and VerticalAlignment properties for aligning display position of the barcode either horizontally or vertically respectively. The HorizontalAlignment property sets the horizontal alignment of the barcode using the HorizontalAlignment enumeration which provides Left, Right,Center and Stretch values.

    Similarly, the VerticalAlignment property sets the vertical alignment of the barcode using the VerticalAlignment enumeration which provides Left, Right, Center and Stretch values.

    You can set the HorizontalAlignment and VerticalAlignment properties of the Barcode control using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="QRCode" Text="ComponentOne@123" HorizontalAlignment="Left" VerticalAlignment="Top"></BarCode:C1BarCode>                   
    
    barCode.HorizontalAlignment = HorizontalAlignment.Left;
    barCode.VerticalAlignment = VerticalAlignment.Top;
    

    QuietZone

    A quiet zone is an area of blank space on either side of a barcode that tells the scanner where the symbology starts and stops. The QuietZone class lets you specify the quiet zone(s) in a BarCode control using the following properties:

    Properties Description
    Left Enters the size of blank space to leave to the left of the barcode.
    Right Enters the size of blank space to leave to the right of the barcode.
    Top Enters the size of blank space to leave at the top of the barcode.
    Bottom Enters the size of blank space to leave at the bottom of the barcode.

    The following image shows Left and Right quiet zones:

    QuietZone

    You can set quiet zone in the Barcode control using the following code snippet:

    <BarCode:C1BarCode.QuietZone>
       <c1Bar:QuietZone Left="5" Right="5"/>
    </BarCode:C1BarCode.QuietZone>
    
    barCode.QuietZone.Left = 5;
    barCode.QuietZone.Right= 5;
    

    CheckSumEnabled

    In barcode, checksums are included to verify the correctness of data. BarCode automatically adds any necessary control symbols and checksums to the value being encoded, depending on the specific encoding being used. Checksums are not required for all types of barcodes because these are included by default in case of some barcodes. For example, in case of Code39 barcode standard, including checksum is optional. On the other hand, it is recommended to be specified in barcode types such as Code128, Code93x etc.

    The C1BarCode class provides CheckSumEnabled property that lets you specify whether the checksum should be added automatically or not. This property can be set to a boolean value i.e. either true or false for including or excluding the checksum in the barcode. For example, the following image shows checksum differences when this property is enabled or disabled in case of Code39 barcode type:

    When Checksum Enabled When Checksum Disabled

    Checksum

    Checksum

    You can set the CheckSumEnabled property for the BarCode control using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="Code39" Text="1234567890" CheckSumEnabled="True"> </BarCode:C1BarCode>
    
    barCode.CheckSumEnabled=true;
    

    Besides the common properties described above, there are properties that are specific to the type of barcodes. The description of these properties on the basis of code types are as follows:

    Ean128Fnc1Options Properties

    The following properties are available in Ean128Fnc1Options class and used for generating barcode when the barcode type is set to EAN128FNC1 :

    Properties Description
    Dpi Lets you specify the resolution of the printer. It takes the integer value.
    BarAdjust Lets you specify the adjustment size by dot.
    ModuleSize Lets you specify the horizontal size of the barcode module. It takes the integer value.

    You can use the preceding properties for generating barcode using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="EAN128FNC1" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">    <BarCode:C1BarCode.Ean128Fnc1Options>
           <c1Bar:Ean128Fnc1Options Dpi="10" BarAdjust="4" ModuleSize="24"></c1Bar:Ean128Fnc1Options> 
        </BarCode:C1BarCode.Ean128Fnc1Options>
    </BarCode:C1BarCode>
    
    barCode.Ean128Fnc1Options.Dpi=10;
    barCode.Ean128Fnc1Options.BarAdjust=4;
    barCode.Ean128Fnc1Options.ModuleSize=24;
    

    Code25intlvOptions Properties

    The following properties are available in Code25intlvOptions class and used for generating barcode when the barcode type is set to Code25intlv:

    Properties Description
    BearBar Lets you select whether or not to display bearer bar to ITF (Interleaved Two of Five) barcode. It takes the boolean value i.e. True or False.
    LineStroke Lets you select the color of the bearer bar.
    LineStrokeThickness Lets you select the line width of the bearer bar. It takes the integer values.

    You can use the preceding properties for generating barcode using the following code snippet:

     <BarCode:C1BarCode x:Name="barCode" CodeType="Code25intlv" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">    <BarCode:C1BarCode.Code25intlvOptions>
             <c1Bar:Code25intlvOptions BearBar="True" LineStroke="Red" LineStrokeThickness="5"></c1Bar:Code25intlvOptions>
        </BarCode:C1BarCode.Code25intlvOptions>
     </BarCode:C1BarCode>
    
    barCode.Code25intlvOptions.BearBar=true;
    barCode.Code25intlvOptions.LineStroke = Windows.UI.Color.FromArgb(255,255,0,0);
    barCode.Code25intlvOptions.LineStrokeThickness = 5;
    

    Code49Options Properties

    The following properties are available in Code49Options class and used for generating barcode when the barcode type is set to Code49:

    Properties Description
    Grouping Lets you use grouping in the barcode. Its value is either True or False.
    Group Obtains or sets group numbers for barcode grouping. Its value is between 0 and 8. If the value of Grouping is True, the range of value of Group is from 0 to 8. If the value of Grouping is False, value of Group is 0. If the value of Grouping is True, and the Group value is smaller than 0 or larger than 8, the BarCodeException.EnumErrorCode.Code49GroupNo will be thrown.

    You can set the preceding properties for generating barcode using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="Code49" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">    <BarCode:C1BarCode.Code49Options>
              <c1Bar:Code49Options Group="3" Grouping="True" ></c1Bar:Code49Options>
        </BarCode:C1BarCode.Code49Options>
    </BarCode:C1BarCode>
    
    barCode.Code49Options.Group = 3;
    

    DataMatrixOptions Properties

    The following properties are available in DataMatrixOptions class and used for generating barcode when the barcode type is set to DataMatrix

    Properties Description
    EccMode Lets you select the ECC mode. The possible values are ECC000, ECC050, ECC080, ECC100, ECC140, or ECC200.
    Ecc200SymbolSize Lets you select the size of ECC200 symbol. The default value is SquareAuto.
    Ecc200EncodingMode Lets you select the ECC200 encoding mode. The possible values are Auto, ASCII, C40, Text, X12, EDIFACT, or Base256.
    Ecc000_140SymbolSize Lets you select the size of the ECC000_140 symbol.
    StructuredAppend: Lets you select whether the current barcode symbol is part of structured append symbols.
    StructureNumber: Lets you specify the structure number of current symbol within the structured append symbols. The range of this value is from 0 to 15.
    FileIdentifier Lets you specify the file identifier of a related group of structured append symbols. The valid file indentifier value should be within [1,254]. Setting file identifier to 0 lets the file identifier to be calculated automatically.

    You can use the preceding properties for generating barcode using the following code snippet:

     <BarCode:C1BarCode x:Name="barCode" CodeType="DataMatrix" CaptionPosition="Below" Grid.Column="1" BorderThickness="2" HorizontalAlignment="Left" VerticalAlignment="Top">
          <BarCode:C1BarCode.DataMatrixOptions>
             <c1Bar:DataMatrixOptions EccMode="ECC000" Ecc200SymbolSize="Rectangular12x36" ></c1Bar:DataMatrixOptions>
           </BarCode:C1BarCode.DataMatrixOptions>
    </BarCode:C1BarCode>
    
    barCode.DataMatrixOptions.EccMode = DataMatrixEccMode.ECC000;
    barCode.DataMatrixOptions.Ecc200SymbolSize = DataMatrixEcc200SymbolSize.Rectangular12x36;
    

    GS1CompositeOptions Properties

    The following properties are available in GS1CompositeOptions class and used for generating barcode when the barcode type is set to RSS14Stacked or RSSLimited :

    Properties Description
    Type Lets you select the composite symbol type. Its value can be None,CCA or CCB. CCA (Composite Component - Version A) is the smallest variant of the 2-dimensional composite component.
    Value Lets you specify the CCA or CCB character data.

    You can set the preceding properties for generating barcode using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="RSS14Stacked" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">
              <BarCode:C1BarCode.GS1CompositeOptions>     
                     <c1Bar:GS1CompositeOptions Type="CCA" Value="ComponentOne@123" > </c1Bar:GS1CompositeOptions>   
              </BarCode:C1BarCode.GS1CompositeOptions>               
    </BarCode:C1BarCode>
    
    barCode.GS1CompositeOptions.Type = GS1CompositeType.CCA;
    barCode.GS1CompositeOptions.Value = "ComponentOne@123" ;
    

    MicroPDF417Options Properties

    The following properties are available in MicroPDF417Options class and used for generating barcode when the barcode type is set to MicroPDF417:

    Properties Description
    CompactionMode Lets you select the type of CompactionMode. The possible values are Auto, TextCompactionMode,NumericCompactionMode, and ByteCompactionMode.
    FileID Lets you specify the file id of structured append symbol. It takes the value from 0 to 899. If this value is smaller than 0 or larger than 899, the BarCodeException.EnumErrorCode.MicroPDF417FileID is thrown.
    SegmentCount Lets you specify the segment count of structured append symbol. It takes the value from 0 to 99999. If this value is smaller than 0 or larger than 99999, the BarCodeException.EnumErrorCode.MicroPDF417SegmentCount is thrown.
    SegmentIndex Lets you specify the segment index of structured append symbol. It takes the value from 0 to 99998 and less than the value of segment count. If this value is smaller than 0 or larger than 99998, the BarCodeException.EnumErrorCode.MicroPDF417SegmentIndex is thrown.
    Version Lets you select the symbol size. The default value is ColumnPriorAuto.

    You can use the preceding properties for generating barcode using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="MicroPDF417" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">
                 <BarCode:C1BarCode.MicroPDF417Options>  
                    <c1Bar:MicroPDF417Options CompactionMode="NumericCompactionMode" Version="Version1X14" ></c1Bar:MicroPDF417Options> 
                 </BarCode:C1BarCode.MicroPDF417Options>        
    </BarCode:C1BarCode>
    
    barCode.MicroPDF417Options.CompactionMode = MicroPDF417SymbolCompactionMode.NumericCompactionMode;                        barCode.MicroPDF417Options.Version = MicroPDF417SymbolVersion.Version1X14;
    

    PDF417Options Properties

    The following properties are available in PDF417Options class and used for generating barcode when the barcode type is set to PDF417:

    Properties Description
    Column Lets you specify the column numbers for the barcode. It takes the integer value; the default value is -1 and the range of this value is 1 to 30. If this value is not equal to -1 or smaller than 1 or larger than 30, the BarCodeException.EnumErrorCode.PDF417Col is thrown.
    Row Lets you specify the row numbers for the barcode. It takes the integer value; the default value is -1 and the range of this value is from 3 to 90. If this value is not equal to -1 or smaller than 3 or larger than 90, the BarCodeException.EnumErrorCode.PDF417Row is thrown.
    ErrorLevel Lets you specify the error correction level for the barcode. It takes the integer value; the value is -1 or the range of this value is from 0 to 8. If this value is not equal to -1 or is smaller than 0 or larger than 8, the BarCodeException.EnumErrorCode.PDF417ErrorLevel is thrown.
    Type Lets you select the type of PDF417 barcode. The available types are Normal and Simple.

    You can use the preceding properties for generating barcode using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="PDF417" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">      
             <BarCode:C1BarCode.PDF417Options>    
                <c1Bar:PDF417Options Type="Simple" ErrorLevel="5"></c1Bar:PDF417Options>    
             </BarCode:C1BarCode.PDF417Options>        
    </BarCode:C1BarCode>
    
    barCode.PDF417Options.Type = PDF417Type.Normal;
    barCode.PDF417Options.ErrorLevel = 5;
    

    QRCodeOptions Properties

    The following properties are available in QRCodeOptions class and used for generating barcode when the barcode type is set to QRCode:

    Properties Description
    Model Lets you select the model of QRCode. The available models are Model1 and Model2.
    ErrorLevel Lets you select the error correction level for the barcode. The available options are Low, Medium, Quality, and High.
    Version Lets you specify the version of the barcode.
    Mask Lets you select the pattern used for masking barcode. In order to make sure QRCode being successfully read, mask process is required to balance brightness. The options available are Auto, Mask000 Mask001, Mask010, Mask011, Mask100, Mask101, Mask110, and Mask111.
    Connection Lets you select whether connection is used for the barcode. It takes the value True of False.
    ConnectionNumber Lets you specify the connection number for the barcode. It takes the integer value ranging from 0 to 15. If this value is smaller than 0 or larger than 15, EnumErrorCode.QRCodeConnectionNo exception will be thrown.
    Encoding Lets you select the encoding for the barcode. It takes the integer value.

    You can set the preceding properties for generating barcode using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="QRCode" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">
           <BarCode:C1BarCode.QRCodeOptions>
              <c1Bar:QRCodeOptions Model="Model2" ErrorLevel="High"></c1Bar:QRCodeOptions> 
           </BarCode:C1BarCode.QRCodeOptions>           
    </BarCode:C1BarCode>
    
    barCode.QRCodeOptions.Model = QRCodeModel.Model2;
    barCode.QRCodeOptions.ErrorLevel = QRCodeErrorLevel.High;
    

    RssExpandedStackedOptions Properties

    The following property is available in RssExpandedStackedOptions class and used for generating barcode when the barcode type is set to RssExpandedStacked:

    Property Description
    RowCount Lets you specify the number of stacked rows. It takes the integer value; the range is from 1 to 11. If this value is smaller than 1 or larger than 11, the BarCodeException.EnumErrorCode.RSSExpandedStackedCount is thrown. .

    You can set the preceding properties for generating barcode using the following code snippet:

    <BarCode:C1BarCode x:Name="barCode" CodeType="RSSExpandedStacked" CaptionPosition="Below" Grid.Column="1" BorderThickness="2"  HorizontalAlignment="Left" VerticalAlignment="Top">    
              <BarCode:C1BarCode.RssExpandedStackedOptions> <c1Bar:RssExpandedStackedOptions RowCount="1" ></c1Bar:RssExpandedStackedOptions>    
              </BarCode:C1BarCode.RssExpandedStackedOptions>       
    </BarCode:C1BarCode>
    
    barCode.RssExpandedStackedOptions.RowCount = 1;