Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
845
XamCode128Barcode not showing text when created in code
posted

I have the following XAML inside a user control of mine to display a barcode. This works fine when the barcode has to be displayed on the application's UI.

<ig:XamCode128Barcode CodeType="Standard"
                      Data="{Binding Sku}"
                      ShowText="True"
                      ErrorMessageText=""
                      BarsFillMode="EnsureEqualSize"
                      UseLayoutRounding="True"
                      Stretch="Uniform"
                      Background="Transparent"/>

This is what get's displayed on the UI:

Ideally I'd use this for printing the barcode as well, but for reasons I don't understand the surrounding code doesn't work.

To avoid this problem I've modified the code so that it creates the barcode in code:

var element = new XamCode128Barcode
{
Data = item.Sku     CodeType = Code128CodeType.Standard,     ShowText = true,     BarsFillMode = BarsFillMode.EnsureEqualSize,     UseLayoutRounding = true,     Stretch = Stretch.Uniform,     MinHeight = 40,     MinWidth = 180,     Foreground = Brushes.Black,     Background = Brushes.White };

This works in so far as it displays the barcode. However, it doesn't display the text as shown in this screenshot of a PDF created by the printing code.

The code is correct and scans.

I've tried this with other barcode types and they exhibit the same behaviour.

What am I missing here? Why doesn't the text display? It's not a data binding issue as the "ShowText" property is set explicitly.