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
Implements
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:
|
See Also
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:
|
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:
|
TextSpacing
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
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.
|
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
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:
|
See Also
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 |
---|
Microsoft.UI.Xaml.Automation.Peers.AutomationPeer |