简体   繁体   English

WindowsFormsHost - 文本环绕和剪切

[英]WindowsFormsHost - Text Wrapping and Cut Off

This is my WindowsForm user control. 这是我的WindowsForm用户控件。 It is using an Infragistics UltraGroupBox. 它使用的是Infragistics UltraGroupBox。 用户控制

When I try to host this control in a WPF Window and a WindowsFormsHost, the text "Integrated Security" suddenly wraps and is cut off. 当我尝试在WPF窗口和WindowsFormsHost中托管此控件时,文本“集成安全性”突然包装并被切断。 Also the "Select Type" text from another user control is cut off on the bottom (notice the y). 此外,另一个用户控件的“选择类型”文本在底部被截断(注意y)。 在此输入图像描述

How do I get my control not to wrap the text when hosted in a WindowsFormsHost since it fits fine (with some space) in the UserControl I'm using? 当我在WindowsFormsHost中托管时,如何让我的控件不包装文本,因为它在我正在使用的UserControl中适合(有一些空间)? Can anyone explain what is happening? 任何人都可以解释发生了什么?

After reading the two posts that I linked to above, I was able to fix my issue by changing the FontFamily and FontSize. 在阅读了我上面链接的两篇帖子后,我能够通过更改FontFamily和FontSize来解决我的问题。 Now the font won't match all the other controls in my WPF Window, but the text doesn't wrap and get cut off. 现在,该字体将与我的WPF窗口中的所有其他控件不匹配,但文本不会换行并被切断。

<WindowsFormsHost FontFamily="Microsoft Sans Serif" FontSize="11" x:Name="MyHost" Margin="0,0,0,20" /> 

The key changes are 关键的变化是

  • FontFamily="Microsoft Sans Serif" FontFamily =“Microsoft Sans Serif”
  • FontSize="11" 字号= “11”

Text renders differently on WPF window and inside ElementHost 文本在WPF窗口和ElementHost内部呈现不同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM