C# 代码39条形码

C# 代码39条形码,c#,wpf,code39,C#,Wpf,Code39,也许有一个简单的解决办法,但我似乎找不到一个,我需要增加条码的高度而不增加字体大小 // Barcode Text Block TextBlock barcode = new TextBlock(); barcode.Text = "12345678-123"; barcode.FontFamily = new FontFamily("Free 3 Of 9");

也许有一个简单的解决办法,但我似乎找不到一个,我需要增加条码的高度而不增加字体大小

                // Barcode Text Block
                TextBlock barcode = new TextBlock();
                barcode.Text = "12345678-123";
                barcode.FontFamily = new FontFamily("Free 3 Of 9");
                barcode.Margin = new Thickness(736, 638, 0, 50);
                barcode.FontSize = 65;
                page.Children.Add(barcode);

                // Baarcode Number Text Block
                TextBlock pageText = new TextBlock();
                string s = "*12345678-123*";
                s = s.Insert(1, " ").Insert(3, " ").Insert(5, " ").Insert(7, " ").Insert(9, " ").Insert(11, " ").Insert(13, " ").Insert(15, " ").Insert(17, " ").Insert(19, " ").Insert(21, " ").Insert(23, " ").Insert(25, " ");
                pageText.Text = s;

                pageText.FontFamily = new FontFamily("Arial");
                pageText.Margin = new Thickness(743, 685, 0, 50);
                pageText.FontSize = 26;          
                page.Children.Add(pageText);
目前看起来是这样的:

我需要条形码的高度大约高10像素,而不使它更宽。高度属性没有影响它。

这是一个示例

// Barcode Text Block
TextBlock barcode = new TextBlock();
barcode.Text = "12345678-123";
barcode.FontFamily = new FontFamily("Free 3 Of 9");
barcode.Margin = new Thickness(736, 638, 0, 50);
barcode.FontSize = 65;
//apply scale
barcode.RenderTransform = new ScaleTransform() { ScaleY = 1.1 };

此转换将条形码元素缩放到10%的额外高度,您可以根据需要进行调整。

您是指字体字符的高度吗?barcode.FontSize会增加字体大小,从而增加条形码的宽度和高度。我想保持与当前完全相同的宽度,但增加其高度,因为当前条形码太薄。我不确定是否可以使用字体(当然,如果您不想创建自己的字体),但也许您可以使用ScaleTransform-。我只是不知道如何使它保持不变(不依赖于触发器)。在Y方向使用ScaleTransform进行RenderTransform可能会有所帮助。太好了!那正是我要找的!谢谢太好了!快乐编码:)