6

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
La bla bla
  • 8,558
  • 13
  • 60
  • 109
  • Do you have any event handler on text change? Can't reproduce this on a simple wpf app – CharithJ Dec 25 '16 at 10:16
  • No, But on the window containing the `UserControl` I have this http://stackoverflow.com/a/19579704/975959 in order to support multi resolution – La bla bla Dec 25 '16 at 11:12

1 Answers1

3

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.

Community
  • 1
  • 1
Aly Elhaddad
  • 1,913
  • 1
  • 15
  • 31
  • 2
    Thanks, I tried replacing the Behavior with the ViewBox, but it didn't solve the Caret issue, Still sometimes missing. – La bla bla Dec 25 '16 at 15:11