【问题标题】:How to disable text box after it is edited in windows phone app 8.1?在 windows phone 应用程序 8.1 中编辑文本框后如何禁用它?
【发布时间】:2015-05-06 15:16:35
【问题描述】:

我正在尝试创建一个文本框,在第一次在 Windows 8.1 手机应用程序中输入值后,该文本框将无法编辑。怎么可能?

【问题讨论】:

  • 任何答案对您有用吗?如果是这样,您应该将其中一个标记为已接受,以便将来的用户知道它对您有用。如果不是,您应该询问更多详细信息或解释
  • 是的,刚刚检查过。标记。谢谢

标签: c# windows xaml windows-phone-8.1


【解决方案1】:

您只需要了解LostFocus (https://msdn.microsoft.com/en-us/library/windows.ui.xaml.uielement.lostfocus.aspx) 事件和IsEnabled 属性(https://msdn.microsoft.com/it-it/library/system.windows.controls.control.isenabled%28v=vs.95%29.aspx)。

private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
    var textbox = (TextBox)sender;
    textbox.IsEnabled = !(textbox.Text.Length > 0 && textbox.IsEnabled);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多