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