简体   繁体   English

如何在TextBox的右上角设置TextBox光标

[英]How to set TextBox cursor on the rigth corner of the TextBox

How to set TextBox cursor on the right corner of the TextBox . 如何设置TextBox光标在右上角TextBox

像这样:

While there's a Text inside the TextBox 虽然Text框内有TextBox

You can use HorizontalContentAlignment property: 您可以使用HorizontalContentAlignment属性:

<TextBox HorizontalContentAlignment="Right" VerticalAlignment="Top"/>

The result: 结果:

在此处输入图片说明

If you want to set the Caret position, you have to play with CaretIndex property,for example: 如果要设置插入符号位置,则必须使用CaretIndex属性,例如:

<TextBox Text="Username" CaretIndex="0"/>;

But as @NicoRiff says in a comment, what you probably want is a PlaceHolder. 但是正如@NicoRiff在评论中所说,您可能想要的是PlaceHolder。 If that's the case, see this question 如果是这样,请参阅此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM