本文介绍了具有类型封面的Surface上的奇怪自动更正行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

前面只是一个小信息,我没有带有Type Cover的Surface,这是我从用户那里听到的,我可以使用普通PC和无Surface平板电脑重现问题。 
$


我已经在字符X上构建了一个带有自动换行符的文本框,每次最后一个单词跳到下一行,单词开始大写。 

这只在小费时发生,而不是在他只是复制文本时,另外他必须输入Type Cover,如果他使用虚拟键盘问题也没有出现。 
$


我无法粘贴整个代码;这是一段应该有同样问题的代码:

Just a small information up front, I don't have a Surface with Type Cover, this is what I heard from a user, I can't reproduce the problem with a normal PC and a none Surface tablet. 

I have built a Textbox with auto line break at character X, each time when the courser with the last word jumps in the next line, the word starts capitalized. 
This only happens while tipping, not when he just copies the text in, additional he must type with Type Cover, if he uses the virtual keyboard the problem also doesn't show up. 

I can't paste the whole code in; here is a piece of code that should have the same problem:

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <TextBox Grid.Row="2" x:Name="cMessageBox"
                IsSpellCheckEnabled="True"
                MinWidth="200"
                MinHeight="200"
                TextWrapping="NoWrap"
                AcceptsReturn="True" 
                FontSize="14.5" 
                Padding="0,20,0,0" 
                FontFamily="Consolas" TextChanged="cMessageBox_TextChanged" 
                />
    </Grid>
</Page>


    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private void cMessageBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            Windows.UI.Xaml.Controls.TextBox t = sender as Windows.UI.Xaml.Controls.TextBox;
            if (t != null)
            {
                t.TextChanged -= cMessageBox_TextChanged;
                string text = t.Text;

                int index = text.LastIndexOf(' ');
                int indexEnd = text.LastIndexOf('\n');
                if (index - indexEnd > 20)
                {
                    t.Text = text.Insert(index, "\n");
                    t.SelectionStart = index + 1;
                }

                t.TextChanged += cMessageBox_TextChanged;
            }
        }
    }




谢谢你




Thanks


推荐答案

我查看您提供的代码,但是我不知道你在做什么。从代码中,似乎你是控件文本自动换行。但是在TextBox控件中有一个TextWrapping属性,我们使用该属性来做同样的事情。我糊涂了。

I check the code you provide, but I don’t know what you are doing. From the code, it seems you are control text auto wrap. But there is a TextWrapping property in TextBox control, we use the property to do the same. I’m confused.

>我已经在字符X处构建了一个带有自动换行符的文本框,每次当最后一个单词的courser跳到下一行时,单词开始大写。这只会在小费时发生,而不是在他只是复制文本时,另外他必须使用Type Cover键入
,如果他使用虚拟键盘,问题也不会显示。

>I have built a Textbox with auto line break at character X, each time when the courser with the last word jumps in the next line, the word starts capitalized. This only happens while tipping, not when he just copies the text in, additional he must type with Type Cover, if he uses the virtual keyboard the problem also doesn't show up.

我也没有设备。所以我在windows store app项目中测试。没有这样的问题。我的建议是尝试联系此人以了解有关它的更多信息。

I have no device too. So I test in windows store app project. There is no such issue. My suggestion is try to contact the person to know more information about it.

问候,


这篇关于具有类型封面的Surface上的奇怪自动更正行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 20:27