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.
That solved it. Thank you very much.
I would never have thought of calling that method.
Hello Chris,
Thank you for your post.
Most likely it’s a timing issue .During my testing I was able to reproduce the issue , I used Barcode.ExportVisualData(); method solved it.
Attached my sample application here. If this dosent help then provide your sample application for further investigation.
Regards,
8407.WpfApp1.zip