我正在开发一个包含 TextBox
组件的 WPF 应用程序。
我对文本框的插入符号有疑问。看起来,根据 TextBox
本身的位置,插入符号会在某些特定位置消失
插入符号显示:
插入符消失:
插入符返回:
TextBox
样式非常简单:
<Style TargetType="{x:Type TextBox}" x:Key="FormTextBox">
<Setter Property="Width" Value="464"/>
<Setter Property="Height" Value="74"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="FontFamily" Value="Microsoft Sans Serif"/>
<Setter Property="FontSize" Value="43.2"/>
<Setter Property="MaxLength" Value="50"/>
</Style>
我什至尝试将字体设置为 Courier New
,这是等宽字体,同样的事情。
最佳答案
这个问题似乎在比例转换中很常见( 1 , 2 ),你在评论中提到的行为正在应用它。
mainElement.LayoutTransform = scaleTransform;
从 MSDN 开始,没有
effective solution for this issue.
所以,如果你想支持多分辨率,我会推荐 ViewBox ;简单,完成工作。
关于c# - WPF 文本框插入符消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41319889/