【问题标题】:How to go to the next line of a text box programmatically in wp7?如何在 wp7 中以编程方式转到文本框的下一行?
【发布时间】:2013-12-11 08:43:50
【问题描述】:

我正在使用文本框输入一些详细信息。我想要的是,当我按下软键盘的回车键时,我希望光标移动到下一行。

在 xaml 中,

<TextBox x:Name="TextBox" 
    BorderThickness="1" 
    KeyDown="TextBox_KeyDown" 
    Background="Transparent" 
    TextChanged="TextBox_TextChanged_1" 
    HorizontalAlignment="Left" 
    Height="198" 
    argin="10,172,0,0" 
    TextWrapping="Wrap" 
    VerticalAlignment="Top" 
    Width="436"/>

在后面的代码中,

private void TextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    {
        if (e.Key == System.Windows.Input.Key.Enter)
        {
           // How to handle??
        }
    }

如何处理?? 提前致谢!

【问题讨论】:

  • 启用多行属性。
  • @ChilakaUmesh wpf 文本框中没有 MultiLineEnableMultiLine 属性。

标签: c# xaml windows-phone-7


【解决方案1】:

您不需要以这种方式处理 Enter 键。

您可以简单地将属性AcceptsReturn 设置为true:

<TextBox x:Name="TextBox"
     AcceptsReturn="True"
     .....

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多