【问题标题】:Selecting specific textbox to focus for Windows Phone 8为 Windows Phone 8 选择要关注的特定文本框
【发布时间】:2014-02-11 02:03:25
【问题描述】:

我试图在选择时清空文本框。我有多个文本框。如何动态选择特定的文本框?以下是我的代码:

private void newToDoTextBox_GotFocus(object sender, RoutedEventArgs e)
    {
        // Clear the text box when it gets focus.

        newToDoTextBox.Text = String.Empty;
        newToDoTextBox2.Text = String.Empty;
    }

【问题讨论】:

  • “动态选择特定文本框”是什么意思?是否要使用 newToDoTextBox_GotFocus 与两个控件共同选择动作?
  • 例如,我想点击 textbox1 并清除 textbox1。它可以工作,但当我不点击它时 textbox2 也会清除
  • 嗨,请阅读我的回答。
  • 看到了,一会儿再测试,因为我还在外面吃午饭

标签: c# xaml windows-phone-7 windows-phone-8 textbox


【解决方案1】:

请试试这个方法:

// use this method to your 2 textbox
private void yourTextBox_GotFocus(object sender, RoutedEventArgs e)
{
    (sender as TextBox).Text = string.Empty;
}

【讨论】:

  • 您好,感谢您的回复。我会尽快做,因为我现在不在。谢谢
  • 有效!谢谢您的帮助。你得到的对象将其称为文本框并将其转换为文本。现在它是有道理的。我不知道对象发送者可以以这种方式使用。又学到新东西了,谢谢!
猜你喜欢
  • 2014-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-02
  • 1970-01-01
  • 2012-11-18
  • 2014-03-08
  • 1970-01-01
相关资源
最近更新 更多