WPF TextBox Caret Disappearing

一笑奈何 提交于 2019-12-23 10:52:31

问题


I'm developing a WPF application that has TextBox components.

I'm having a problem with the caret of the text boxes. It seems that, depending on the location of the TextBox itself, the caret disappears on certain specific locations

Caret showing:

Caret disappears:

Caret returns:

The TextBox style is very simple:

<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>

I tried even setting the font to Courier New which is monospace font, same thing.


回答1:


The problem seems to be common (1, 2) with the scale transformation, which is being applied by the behavior you mentioned in comments.

mainElement.LayoutTransform = scaleTransform;

And from MSDN, there's no

effective solution for this issue.

So, if you want to support multi-resolution, I would recommend ViewBox; simple, and do the job.



来源:https://stackoverflow.com/questions/41319889/wpf-textbox-caret-disappearing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!