简体   繁体   English

xaml文本框控件中的游标位置

[英]Cursor position in xaml textbox control

Is there a way to align cursor position in Textbox XAML control? 有没有办法在Textbox XAML控件中对齐光标位置?

I have this Textbox: 我有这个文本框:

在此输入图像描述

As you can see the Cursor is slightly upper than the middle position. 正如您所看到的,Cursor略高于中间位置。 Is there any way to fix it? 有什么办法可以解决吗? Or any work around for this issue? 或者解决这个问题的任何工作?

That's happening in Windows Phone 8.1 platform, however on UWP the Textbox cursor perfectly centered. 这种情况发生在Windows Phone 8.1平台上,但是在UWP上,Textbox光标完全居中。

要使TextBox中的文本居中,请使用TextBox的VerticalContentAlignment属性。

<TextBox Text="The text" Height="40" VerticalContentAlignment="Center" />

I've added Padding="8,3,0,0" which sets the cursor in the middle (as a workaround) If anyone has better idia I would love to hear it :) 我添加了Padding =“8,3,0,0”,它将光标设置在中间(作为解决方法)如果有人有更好的idia我会很乐意听到它:)

This solution sets the cursor in the middle, but the text isn't centered now... 此解决方案将光标设置在中间,但文本现在不居中...

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

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