syncfusion-winui-barcode
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Barcodes (SfBarcode)
实现条码功能(SfBarcode)
The Syncfusion WinUI Barcode control (SfBarcode) generates and displays data in machine-readable barcode formats. It supports both one-dimensional (linear) and two-dimensional barcodes with extensive customization options for appearance, text display, and symbology-specific settings.
Syncfusion WinUI 条码控件(SfBarcode)可将数据生成并展示为机器可识别的条码格式。它同时支持一维(线性)和二维条码,提供丰富的自定义选项,可调整外观、文本展示效果以及码制专属设置。
When to Use This Skill
何时使用本技能
Use this skill when you need to:
- Generate barcodes or QR codes in WinUI applications
- Encode text, numbers, or data into machine-readable formats
- Display product codes, inventory labels, or shipping information
- Create scannable codes for mobile devices (QR, DataMatrix)
- Implement barcode printing functionality
- Customize barcode appearance (colors, rotation, text display)
- Choose appropriate symbology for specific data types
- Configure symbology-specific settings (error correction, encoding, checksums)
当你需要完成以下需求时可使用本技能:
- 在WinUI应用中生成条码或QR码
- 将文本、数字或数据编码为机器可识别格式
- 展示产品码、库存标签或物流信息
- 生成可供移动设备扫描的码(QR、DataMatrix)
- 实现条码打印功能
- 自定义条码外观(颜色、旋转角度、文本展示)
- 为特定数据类型选择合适的码制
- 配置码制专属设置(纠错、编码、校验和)
Component Overview
组件概述
Key Capabilities:
- 15 Symbology Types: 12 one-dimensional + 3 two-dimensional barcode formats
- Flexible Text Display: Customizable alignment, spacing, and visibility
- Visual Customization: Colors, bar widths, rotation angles
- Symbology Settings: Type-specific configurations (checksums, encoding, error correction)
- XAML and Code-Behind Support: Declarative and programmatic implementation
Common Use Cases:
- Product labeling (UPC, EAN codes)
- Inventory management (Code39, Code128)
- Shipping labels (GS1-128, DataMatrix)
- QR codes for URLs, contact info, Wi-Fi credentials
- Document tracking (Code93, PDF417)
- Healthcare labels (Code32 pharmaceuticals)
核心能力:
- 15种码制类型: 12种一维条码 + 3种二维条码格式
- 灵活的文本展示: 可自定义对齐方式、间距和可见性
- 可视化自定义: 颜色、条码宽度、旋转角度
- 码制专属设置: 不同码制的专属配置(校验和、编码、纠错)
- 支持XAML和代码后置实现: 支持声明式和编程式两种实现方式
常见使用场景:
- 产品标签(UPC、EAN码)
- 库存管理(Code39、Code128)
- 物流标签(GS1-128、DataMatrix)
- 用于存储URL、联系信息、Wi-Fi凭证的QR码
- 文档追踪(Code93、PDF417)
- 医疗保健标签(Code32 药品标识)
Documentation and Navigation Guide
文档与导航指南
Getting Started
入门指南
📄 Read: references/getting-started.md
Use this when you need to:
- Install the Syncfusion.Barcode.WinUI NuGet package
- Set up a new WinUI project with barcode control
- Add namespace imports (XAML: , C#:
using:Syncfusion.UI.Xaml.Barcode)using Syncfusion.UI.Xaml.Barcode - Create your first barcode with basic configuration
- Understand the minimal code required (Value + Symbology)
Topics Covered:
- Creating WinUI 3 desktop application
- NuGet package installation
- Namespace configuration in XAML and C#
- Basic SfBarcode declaration
- Setting symbology (CodabarBarcode example)
- Initial working example
📄 阅读: references/getting-started.md
当你需要完成以下操作时使用本部分:
- 安装Syncfusion.Barcode.WinUI NuGet包
- 新建带条码控件的WinUI项目
- 添加命名空间导入(XAML: ,C#:
using:Syncfusion.UI.Xaml.Barcode)using Syncfusion.UI.Xaml.Barcode - 基于基础配置创建你的第一个条码
- 理解最低要求代码(值 + 码制)
覆盖的主题:
- 创建WinUI 3桌面应用
- NuGet包安装
- XAML和C#中的命名空间配置
- 基础SfBarcode声明
- 设置码制(CodabarBarcode示例)
- 初始可运行示例
Symbology Types
码制类型
📄 Read: references/symbology-types.md
Use this when you need to:
- Choose the correct barcode type for your data
- Understand differences between 1D and 2D barcodes
- Learn which characters each symbology supports
- Implement specific barcode types (Codabar, Code39, Code128, QR, DataMatrix, etc.)
- Encode different data types (numeric-only, alphanumeric, full ASCII, binary)
Covered Symbologies:
- 1D Barcodes: Codabar, Code11, Code32, Code39, Code39Extended, Code93, Code93Extended, Code128A/B/C, UPC, GS1Code128
- 2D Barcodes: QRBarcode, DataMatrixBarcode, Pdf417Barcode
- Character set tables for each type
- Industry-specific use cases
📄 阅读: references/symbology-types.md
当你需要完成以下操作时使用本部分:
- 为你的数据选择合适的条码类型
- 理解一维和二维条码的区别
- 了解每种码制支持的字符范围
- 实现特定条码类型(Codabar、Code39、Code128、QR、DataMatrix等)
- 编码不同类型的数据(仅数字、字母数字、全ASCII、二进制)
覆盖的码制:
- 一维条码: Codabar、Code11、Code32、Code39、Code39Extended、Code93、Code93Extended、Code128A/B/C、UPC、GS1Code128
- 二维条码: QRBarcode、DataMatrixBarcode、Pdf417Barcode
- 每种码制的字符集对照表
- 行业专属使用场景
Text Customization
文本自定义
📄 Read: references/text-customization.md
Use this when you need to:
- Show or hide the encoded text below the barcode
- Adjust spacing between barcode and text
- Align text horizontally (Left, Center, Right)
- Align text vertically (Top, Bottom)
- Control text visibility with ShowValue property
Customization Options:
- Value property (encoded text)
- ShowValue (display toggle)
- TextSpacing (gap between bars and text)
- HorizontalTextAlignment
- VerticalTextAlignment
📄 阅读: references/text-customization.md
当你需要完成以下操作时使用本部分:
- 展示或隐藏条码下方的编码文本
- 调整条码和文本之间的间距
- 水平对齐文本(左对齐、居中、右对齐)
- 垂直对齐文本(顶部、底部)
- 通过ShowValue属性控制文本可见性
自定义选项:
- Value属性(编码文本)
- ShowValue(展示开关)
- TextSpacing(条码和文本的间距)
- HorizontalTextAlignment(水平文本对齐)
- VerticalTextAlignment(垂直文本对齐)
Visual Customization
可视化自定义
📄 Read: references/visual-customization.md
Use this when you need to:
- Change barcode colors (Background, Foreground)
- Adjust bar width ratios (Module property)
- Enable auto-sizing for QR and DataMatrix codes
- Rotate barcodes (0°, 90°, 180°, 270°)
- Ensure scanner readability with proper contrast
Customization Features:
- Background and Foreground colors
- Module width for 1D barcodes
- AutoModule for 2D barcodes
- RotationAngle with BarcodeRotation enum
- Scanner contrast considerations
📄 阅读: references/visual-customization.md
当你需要完成以下操作时使用本部分:
- 修改条码颜色(背景色、前景色)
- 调整条码宽度比例(Module属性)
- 为QR和DataMatrix码开启自动尺寸适配
- 旋转条码(0°、90°、180°、270°)
- 通过合适的对比度保证扫描器可识别
自定义功能:
- 背景色和前景色
- 一维条码的Module宽度
- 二维条码的AutoModule自动尺寸
- 基于BarcodeRotation枚举的RotationAngle旋转角度
- 扫描器对比度注意事项
Symbology-Specific Settings
码制专属设置
📄 Read: references/symbology-settings.md
Use this when you need to:
- Configure checksum options for 1D barcodes
- Set encoding format for DataMatrix barcodes
- Choose matrix size for DataMatrix
- Configure QR code version and error correction level
- Set input mode for QR codes
- Add start/stop symbols for barcode readers
Configuration Options:
- 1D Settings: EnableCheckSum, ShowCheckSum, EncodeStartStopSymbols
- DataMatrix: Encoding (ASCII/ASCIINumeric/Auto/Base256), MatrixSize (30+ size options)
- QR Code: QRVersion (1-40 or Auto), ErrorCorrectionLevel (Low/Medium/Quartile/High), InputMode (Numeric/AlphaNumeric/Binary)
📄 阅读: references/symbology-settings.md
当你需要完成以下操作时使用本部分:
- 为一维条码配置校验和选项
- 为DataMatrix条码设置编码格式
- 选择DataMatrix的矩阵尺寸
- 配置QR码版本和纠错级别
- 设置QR码的输入模式
- 为条码阅读器添加起始/终止符号
配置选项:
- 一维条码设置: EnableCheckSum、ShowCheckSum、EncodeStartStopSymbols
- DataMatrix: Encoding(ASCII/ASCIINumeric/Auto/Base256)、MatrixSize(30+种尺寸选项)
- QR码: QRVersion(1-40或自动)、ErrorCorrectionLevel(低/中/四分位/高)、InputMode(数字/字母数字/二进制)
Quick Start
快速开始
Minimal Barcode Implementation
最简条码实现
XAML:
xml
<Page xmlns:syncfusion="using:Syncfusion.UI.Xaml.Barcode">
<Grid>
<syncfusion:SfBarcode x:Name="barcode"
Value="48625310"
Height="150">
<syncfusion:SfBarcode.Symbology>
<syncfusion:CodabarBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>
</Grid>
</Page>C#:
csharp
using Syncfusion.UI.Xaml.Barcode;
SfBarcode barcode = new SfBarcode();
barcode.Value = "48625310";
barcode.Height = 150;
barcode.Symbology = new CodabarBarcode();
Root_Grid.Children.Add(barcode);XAML:
xml
<Page xmlns:syncfusion="using:Syncfusion.UI.Xaml.Barcode">
<Grid>
<syncfusion:SfBarcode x:Name="barcode"
Value="48625310"
Height="150">
<syncfusion:SfBarcode.Symbology>
<syncfusion:CodabarBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>
</Grid>
</Page>C#:
csharp
using Syncfusion.UI.Xaml.Barcode;
SfBarcode barcode = new SfBarcode();
barcode.Value = "48625310";
barcode.Height = 150;
barcode.Symbology = new CodabarBarcode();
Root_Grid.Children.Add(barcode);QR Code for URL
生成URL对应的QR码
xml
<syncfusion:SfBarcode x:Name="qrCode"
Value="http://www.syncfusion.com"
Height="200"
Width="200">
<syncfusion:SfBarcode.Symbology>
<syncfusion:QRBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>xml
<syncfusion:SfBarcode x:Name="qrCode"
Value="http://www.syncfusion.com"
Height="200"
Width="200">
<syncfusion:SfBarcode.Symbology>
<syncfusion:QRBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>Common Patterns
常见实现模式
Pattern 1: Product Label Barcode (UPC)
模式1:产品标签条码(UPC)
xml
<syncfusion:SfBarcode Value="012345678905"
Height="150"
Width="300"
HorizontalTextAlignment="Center">
<syncfusion:SfBarcode.Symbology>
<syncfusion:UpcBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>xml
<syncfusion:SfBarcode Value="012345678905"
Height="150"
Width="300"
HorizontalTextAlignment="Center">
<syncfusion:SfBarcode.Symbology>
<syncfusion:UpcBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>Pattern 2: Inventory Code (Code39 with Checksum)
模式2:库存编码(带校验和的Code39)
xml
<syncfusion:SfBarcode Value="ITEM12345" Height="120">
<syncfusion:SfBarcode.Symbology>
<syncfusion:Code39Barcode EnableCheckSum="True"
ShowCheckSum="True" />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>xml
<syncfusion:SfBarcode Value="ITEM12345" Height="120">
<syncfusion:SfBarcode.Symbology>
<syncfusion:Code39Barcode EnableCheckSum="True"
ShowCheckSum="True" />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>Pattern 3: Shipping Label (DataMatrix)
模式3:物流标签(DataMatrix)
xml
<syncfusion:SfBarcode Value="SHIP2024-A45678"
Width="200"
Height="200"
ShowValue="False"
AutoModule="True">
<syncfusion:SfBarcode.Symbology>
<syncfusion:DataMatrixBarcode Encoding="Auto"
MatrixSize="Auto" />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>xml
<syncfusion:SfBarcode Value="SHIP2024-A45678"
Width="200"
Height="200"
ShowValue="False"
AutoModule="True">
<syncfusion:SfBarcode.Symbology>
<syncfusion:DataMatrixBarcode Encoding="Auto"
MatrixSize="Auto" />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>Pattern 4: Rotated Barcode for Vertical Labels
模式4:垂直标签用旋转条码
xml
<syncfusion:SfBarcode Value="VERTICAL123"
RotationAngle="Angle90"
Height="250"
Width="150">
<syncfusion:SfBarcode.Symbology>
<syncfusion:Code128BBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>xml
<syncfusion:SfBarcode Value="VERTICAL123"
RotationAngle="Angle90"
Height="250"
Width="150">
<syncfusion:SfBarcode.Symbology>
<syncfusion:Code128BBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>Pattern 5: QR Code with Error Correction
模式5:带纠错功能的QR码
xml
<syncfusion:SfBarcode Value="https://example.com/product/12345"
Width="250"
Height="250"
ShowValue="False">
<syncfusion:SfBarcode.Symbology>
<syncfusion:QRBarcode ErrorCorrectionLevel="High"
QRVersion="Auto" />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>xml
<syncfusion:SfBarcode Value="https://example.com/product/12345"
Width="250"
Height="250"
ShowValue="False">
<syncfusion:SfBarcode.Symbology>
<syncfusion:QRBarcode ErrorCorrectionLevel="High"
QRVersion="Auto" />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>Pattern 6: Custom Colored Barcode
模式6:自定义颜色条码
xml
<syncfusion:SfBarcode Value="COLORED123"
Background="LightYellow"
Foreground="DarkBlue"
Height="150">
<syncfusion:SfBarcode.Symbology>
<syncfusion:Code128CBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>xml
<syncfusion:SfBarcode Value="COLORED123"
Background="LightYellow"
Foreground="DarkBlue"
Height="150">
<syncfusion:SfBarcode.Symbology>
<syncfusion:Code128CBarcode />
</syncfusion:SfBarcode.Symbology>
</syncfusion:SfBarcode>Key Properties
核心属性
Core Properties
基础属性
| Property | Type | Description |
|---|---|---|
| Value | string | The text/data to encode in the barcode |
| Symbology | BarcodeBase | The barcode type (Codabar, QR, DataMatrix, etc.) |
| ShowValue | bool | Display encoded text below barcode (default: true) |
| Module | double | Bar width ratio for 1D barcodes |
| AutoModule | bool | Auto-size 2D barcodes based on control size |
| RotationAngle | BarcodeRotation | Rotate barcode (Angle0/90/180/270) |
| Background | Brush | Barcode background color |
| Foreground | Brush | Barcode bars/dots color |
| TextSpacing | double | Space between barcode and text |
| HorizontalTextAlignment | TextAlignment | Text horizontal alignment (Left/Center/Right) |
| VerticalTextAlignment | BarcodeTextAlignment | Text vertical position (Top/Bottom) |
| 属性 | 类型 | 描述 |
|---|---|---|
| Value | string | 要编码到条码中的文本/数据 |
| Symbology | BarcodeBase | 条码类型(Codabar、QR、DataMatrix等) |
| ShowValue | bool | 是否在条码下方展示编码文本(默认:true) |
| Module | double | 一维条码的条宽比例 |
| AutoModule | bool | 基于控件尺寸自动调整二维条码大小 |
| RotationAngle | BarcodeRotation | 旋转条码(Angle0/90/180/270) |
| Background | Brush | 条码背景色 |
| Foreground | Brush | 条码条/点的颜色 |
| TextSpacing | double | 条码和文本之间的间距 |
| HorizontalTextAlignment | TextAlignment | 文本水平对齐方式(左对齐/居中/右对齐) |
| VerticalTextAlignment | BarcodeTextAlignment | 文本垂直位置(顶部/底部) |
Symbology Selection Guide
码制选择指南
For numeric-only data:
- Code11, Code32, UpcBarcode, Code128C
For alphanumeric data:
- Code39, Code93, Code128A/B
For full ASCII characters:
- Code39Extended, Code93Extended
For compact 2D codes:
- QRBarcode (URLs, text)
- DataMatrixBarcode (small labels)
For high-capacity data:
- Pdf417Barcode (IDs, transport)
For international products:
- UpcBarcode, GS1Code128Barcode
仅数字数据:
- Code11、Code32、UpcBarcode、Code128C
字母数字混合数据:
- Code39、Code93、Code128A/B
全ASCII字符:
- Code39Extended、Code93Extended
紧凑型二维条码:
- QRBarcode(URL、文本)
- DataMatrixBarcode(小标签)
大容量数据:
- Pdf417Barcode(证件、运输单据)
国际产品:
- UpcBarcode、GS1Code128Barcode
Common Use Cases
常见使用场景
Use Case 1: Product Packaging
场景1:产品包装
Generate UPC barcodes for retail products with centered text display.
When: Creating product labels, retail packaging, price tags
Symbology: UpcBarcode
References: getting-started.md, symbology-types.md
Symbology: UpcBarcode
References: getting-started.md, symbology-types.md
生成零售产品用的UPC条码,带居中文本展示。
适用时机: 创建产品标签、零售包装、价格标签
推荐码制: UpcBarcode
参考文档: getting-started.md、symbology-types.md
推荐码制: UpcBarcode
参考文档: getting-started.md、symbology-types.md
Use Case 2: Warehouse Inventory
场景2:仓库库存
Create scannable codes for inventory tracking with alphanumeric identifiers.
When: Asset tracking, warehouse management, stock control
Symbology: Code39, Code128
References: symbology-types.md, symbology-settings.md
Symbology: Code39, Code128
References: symbology-types.md, symbology-settings.md
生成带字母数字标识的可扫描码,用于库存追踪。
适用时机: 资产追踪、仓库管理、库存控制
推荐码制: Code39、Code128
参考文档: symbology-types.md、symbology-settings.md
推荐码制: Code39、Code128
参考文档: symbology-types.md、symbology-settings.md
Use Case 3: QR Codes for Mobile Scanning
场景3:供移动扫描的QR码
Generate QR codes for URLs, contact information, or Wi-Fi credentials.
When: Marketing materials, business cards, product authentication
Symbology: QRBarcode
References: symbology-types.md, symbology-settings.md
Symbology: QRBarcode
References: symbology-types.md, symbology-settings.md
生成用于存储URL、联系信息或Wi-Fi凭证的QR码。
适用时机: 营销物料、名片、产品验真
推荐码制: QRBarcode
参考文档: symbology-types.md、symbology-settings.md
推荐码制: QRBarcode
参考文档: symbology-types.md、symbology-settings.md
Use Case 4: Shipping Labels
场景4:物流标签
Create compact DataMatrix codes for shipping and logistics.
When: Package tracking, postal services, logistics
Symbology: DataMatrixBarcode, GS1Code128Barcode
References: symbology-types.md, symbology-settings.md
Symbology: DataMatrixBarcode, GS1Code128Barcode
References: symbology-types.md, symbology-settings.md
生成紧凑型DataMatrix码,用于运输和物流场景。
适用时机: 包裹追踪、邮政服务、物流
推荐码制: DataMatrixBarcode、GS1Code128Barcode
参考文档: symbology-types.md、symbology-settings.md
推荐码制: DataMatrixBarcode、GS1Code128Barcode
参考文档: symbology-types.md、symbology-settings.md
Use Case 5: Pharmaceutical Labels
场景5:药品标签
Generate Code32 barcodes for medication packaging and tracking.
When: Healthcare, pharmaceutical industry, prescription labels
Symbology: Code32Barcode
References: symbology-types.md
Symbology: Code32Barcode
References: symbology-types.md
生成Code32条码,用于药品包装和追踪。
适用时机: 医疗保健、制药行业、处方标签
推荐码制: Code32Barcode
参考文档: symbology-types.md
推荐码制: Code32Barcode
参考文档: symbology-types.md
Use Case 6: Document Management
场景6:文档管理
Encode document IDs with PDF417 for archiving and retrieval systems.
When: Document tracking, archival systems, identification cards
Symbology: Pdf417Barcode
References: symbology-types.md
Symbology: Pdf417Barcode
References: symbology-types.md
用PDF417编码文档ID,用于归档和检索系统。
适用时机: 文档追踪、归档系统、身份证件
推荐码制: Pdf417Barcode
参考文档: symbology-types.md
推荐码制: Pdf417Barcode
参考文档: symbology-types.md
Additional Resources
额外资源
- NuGet Package:
Syncfusion.Barcode.WinUI - Namespace:
Syncfusion.UI.Xaml.Barcode - Official Documentation: https://help.syncfusion.com/winui/barcode/
- GitHub Examples: https://github.com/SyncfusionExamples/syncfusion-winui-barcode-examples
- NuGet包:
Syncfusion.Barcode.WinUI - 命名空间:
Syncfusion.UI.Xaml.Barcode - 官方文档: https://help.syncfusion.com/winui/barcode/
- GitHub示例: https://github.com/SyncfusionExamples/syncfusion-winui-barcode-examples