为什么文本渲染在“默认文本”之间有所不同。和“用户键入文本”在UWP TextBox控件中?

发布于 01-24 12:21 字数 1449 浏览 1 评论 0原文

您可以看到第二个文本框(用户键入文本)文本比第一个文本框文本宽。

我在Winui 3中找到了这一点,但在UWP中获得了相同的结果。我无法在WPF中复制它。

这是XAML。

<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <TextBlock
        Grid.Row="0"
        Grid.Column="0"
        Text="Default text" />
    <TextBox
        Grid.Row="0"
        Grid.Column="1"
        Text="TestTestTestTestTestTestTestTestTestTest" />
    <TextBlock
        Grid.Row="1"
        Grid.Column="0"
        Text="Typed text" />
    <TextBox Grid.Row="1" Grid.Column="1" />
</Grid>

我的问题在标题中,但我想知道是否有一种使它们相同的方法。

更新

谢谢@niko Zhu!我尝试了您的建议,正如您提到的,这似乎是 ime ?或 Google日语输入问题。

You can see that the 2nd TextBox (user typed text) text is wider than the 1st TextBox text.

enter image description here

I found this in WinUI 3 but got the same result in UWP. I couldn't reproduce this in WPF.

This is the XAML.

<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <TextBlock
        Grid.Row="0"
        Grid.Column="0"
        Text="Default text" />
    <TextBox
        Grid.Row="0"
        Grid.Column="1"
        Text="TestTestTestTestTestTestTestTestTestTest" />
    <TextBlock
        Grid.Row="1"
        Grid.Column="0"
        Text="Typed text" />
    <TextBox Grid.Row="1" Grid.Column="1" />
</Grid>

My question is in the title but I'd like to know if there is a way to make them identically.

UPDATE

Thanks @Niko Zhu ! I tried your suggestion and as you mentioned, this seems to be an IME? or Google Japanese Input problem.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷默言语 2025-01-31 12:21:43

为什么文本渲染在UWP文本框中的“默认文本”和“用户键入文本”之间有所不同?

我可以通过Chinses键盘输入来重现此问题,它看起来 ime 大写字符大于默认值。请使用我们键盘替换,它将解决问题。

Why the text rendering is different between "default text" and "user typed text" in UWP TextBox control?

I could reproduce this problem with chinses keyboard input, and it looks IME problem that uppercase characters are larger than the default. Please use US keyboard to replace, it will solve the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文