This is a migrated thread and some comments may be shown as answers.

add Barcode to a canvas

2 Answers 132 Views
BarCode
This is a migrated thread and some comments may be shown as answers.
Bart
Top achievements
Rank 1
Bart asked on 11 Nov 2016, 03:54 PM

Hi Guys,

 

I am creating a dynamic canvas to send to the printer and on this canvas I try add an EAN-13 barcode but I can't get it done.

Then I saw, telerik ui for wpf has "RadBarcodeEAN13" but this doesn't show anything.

RadBarcodeEAN13 BarCode = new RadBarcodeEAN13();
BarCode.Text = "871038168385";
cnvPrint.Children.Add(BarCode);
Canvas.SetLeft(BarCode, template.x * positionfactor);
 Canvas.SetTop(BarCode, template.y * positionfactor);
however,
when I do something like this
TextBlock BarCode = new TextBlock();

the specified textBlock is added ad as text to the canvas (cnvPrint) and ends up in my printer.

 

where do I go wrong? unfortunately I'm unable to find any examples for this.

Thank you for your help

2 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 15 Nov 2016, 07:00 PM
Hi Bart,

Can you try adding a height to the barcode? and also to make sure the position is correct, try placing it at the top left of the canvas for a quick test.

I was able to get the Barcode to render in the canvas with the code below and here's a screenshot of the result at runtime.

public MainWindow()
{
            InitializeComponent();
 
            RadBarcodeEAN13 BarCode = new RadBarcodeEAN13();
            BarCode.Text = "871038168385";
            BarCode.Height = 100;
            cnvPrint.Children.Add(BarCode);
            Canvas.SetLeft(BarCode, 0);
            Canvas.SetTop(BarCode, 0);
}


Let us know if this doesn't resolve the problem.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Bart
Top achievements
Rank 1
answered on 16 Nov 2016, 11:29 AM

Hi Lance,

Thank you for the answer,

I did some more tests after your post, and found the following, I added the reference to "Telerik.Windows.Controls.DataVisualization"
for some reason this didn't work.

so I removed the reference and added it againg using the telerik menu in visualstudio.

"telerik / UI for WPF /configure project"

now the reference is added again and it prints EAN barcodes.

I'm not sure what the difference is between those 2 methods but it works.

Tags
BarCode
Asked by
Bart
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Bart
Top achievements
Rank 1
Share this question
or