The RadBarcode suite contains a set of controls that allows you to display different barcodes. This article will walk you through creating a simple application that contains RadBarcode128 control. The same principle can be used to set up the other controls from the suite.
- Assembly References
- Defining the Control and Setting Data
- Showing the Text
- Showing the Checksum
- Restricting the Aspect Ratio
In order to use the controls from the RadBarcode suite, you will need to add references to the following assemblies:
The barcode controls work with text data. After the control is defined (see Example 1) you can set the data via its Text property.
If you data bind the Text property and want the UI to be updated when the view model property is changed you will need to set the binding Mode to TwoWay.
Example 1: Defining the control
<telerik:RadBarcode128 Text="RadBarcodeText" />
Figure 1: RadBarcode128
By default the control displays the value of the Text property under the barcode. You can show or hide this via the ShowText property.
Example 2: Hiding the text
<telerik:RadBarcode128 Text="RadBarcodeText" ShowText="False" />
By default the barcode includes the checksum in the rendered barcode image. To change this you can set the RenderChecksum property to False.
Example 3: Removing the checksum from the rendered image
<telerik:RadBarcode128 Text="RadBarcodeText" RenderChecksum="False" />
By default the checksum is shown in the text field under the barcode. To change this you can set the ShowChecksum property to False.
Example 4: Hiding the checksum
<telerik:RadBarcode128 Text="RadBarcodeText" ShowChecksum="False" />
Figure 1: RadBarcode128 with shown checksum
The control allows you to restrict its aspect ratio. You can do that by setting the RestrictAspectRatio property to True. The ratio is 4 to 1, which means that the Width of the control will be 4 times its Height. For example, if you set Width of 400, the Height will be 100.
Example 4: Restricting the aspect ratio
<telerik:RadBarcode128 Text="RadBarcodeText" RestrictAspectRatio="True" />