RadBarCodeQR - Maintaining the same spacing

1 Answer 21 Views
BarCode
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Ohad asked on 23 Mar 2022, 10:01 AM

I have RadBarcodeQR and I want to keep the white space outside the BarCode the same in all text.

Would appreciate help

<Grid>
        <StackPanel VerticalAlignment="Center">
            <TextBox Text="{Binding QrCode, UpdateSourceTrigger=PropertyChanged}" Width="300" Height="30" Margin="20"/>
            <telerik:RadBarcodeQR
                Height="100" 
                Width="100"
                Text="{Binding QrCode, UpdateSourceTrigger=PropertyChanged}"
                Foreground="Black"
                UseLayoutRounding="True">
                <telerik:RadBarcodeQR.Style>
                    <Style TargetType="telerik:RadBarcodeQR">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="telerik:RadBarcodeQR">
                                    <Grid 
                                        x:Name="PART_RadBarcodeQR" 
                                        Background="White" 
                                        Margin="15">
                                        <Image x:Name="ImageQrCode" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </telerik:RadBarcodeQR.Style>
            </telerik:RadBarcodeQR>
        </StackPanel>
    </Grid>

 

This is what it looks like with an empty string:

 

 

This is what it looks like with the string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

 

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 24 Mar 2022, 03:30 PM

Hello Ohad,

Thank you for the provided code snippet and images.

The reason why the barcode changes its size is due to the automatic calculation of its version based on the data. You can read more about how to determine which version to use in this article: Versions of the QR Code.

By setting a fixed Version and ErrorCorrectionLevel, the barcode will not change its dimensions. On a side note, it is recommended to use the new RadBarcode control instead of the old ones (such as RadBarcodeQR) which will soon be deprecated. Here's an example:

            <telerik:RadBarcode Value="{Binding QrCode, UpdateSourceTrigger=PropertyChanged}" 
                                Height="100" Width="100" x:Name="barcode">
                <telerik:RadBarcode.Symbology>
                    <telerik:QRCode Version="3" ErrorCorrectionLevel="M" />
                </telerik:RadBarcode.Symbology>
            </telerik:RadBarcode>

Please give this a try and let me know if it provides the desired result.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
BarCode
Asked by
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dilyan Traykov
Telerik team
Share this question
or