WPF TextBox Caret Disappearing

2.1k views Asked by At

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 showing

Caret disappears:

Caret disappears

Caret returns:

enter image description here

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

There are 1 answers

1
Aly Elhaddad On

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.