Actually there is an old and shaggy code already, the controls are implemented on WinForms, but there is no time and money to rewrite to WPF. We use it as we can, every time we implement some kind of control in WPF, bugs come out.

Now the bug is a bit specific. There is a control inside the Label control whose width is calculated as follows:

 return (int) LabelControl.CreateGraphics().MeasureString(TextLabel, TextLabel.Font).Width + 40; 

If you look at the WinForms test application, everything is fine. If you put the control inside WPF, it takes the text and if there are spaces there, it transfers the text, it lies.

Is there a hardcode option, replace the line with the modified one, and replace the spaces with any other character, but this is still an assumption, are there any more appropriate and flexible ways?

  • Uh, what does “control inside WPF” mean? - VladD
  • @VladD use inside a WPF application - ParanoidPanda
  • WinForms Control? o_O - VladD
  • @VladD WinForms UserControl - ParanoidPanda
  • one
    @VladD, you can embed anything from WinForms through WinFormsHost . The truth sometimes works specifically. - dm.dymov

1 answer 1

The answer is simple. I rewrote the calculation, added 10 pixels. Why this behavior, and why it is necessary to add 10 pixels, I can’t assume, most likely, in other applications, by the way of the Vinform, Margin is hung on this control.